473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

WebControl/Cache-Control question

Hi,

I am new to WebControls, I have created a WebControl that is used to present
an image, the image bing presented is created on runtime, each client side
button click causes the image to change, this require to prevent this image
from being cached, I have tried to play around with:
Context.Response.AddHeader("Cache-Control", ... )
and with
Context.Response.Cache.SetCacheability(System.Web. HttpCacheability.NoCache)
BUT Still, the image is being extracted from the cache and the changes
cannot be seen...

What am I doing wrong here?
How can I prevent the image from being cached?

Any help, samples or pointers will be appreciated.

--
Nadav
http://www.sophin.com
Nov 16 '05 #1
2 4066
"Nadav" <Na***@discussions.microsoft.com> wrote in message news:9E**********************************@microsof t.com...
How can I prevent the image from being cached?


What you describe sounds like the correct means of preventing caching by
the user agent, provided the user agent understands the header.

The only thing I'd check is that you're setting this on the correct HTTP re-
sponse, that is, the one generating the dynamic image (i.e., I presume else-
where in the same web control you're also setting the HTTP Content-Type
header to something like image/png or something.) The cache-control
won't apply to the image if you're setting it on the HTTP response for the
page as a whole, or if the image is just an <IMG SRC="myimage.png" />
tag that's been rendered. In this situation, the user agent makes two requests,
one to grab your page containing the <IMG> tag, and then a second request
for the .png file specified in that <IMG> tag. If you set cache-control on the
page to expire immediately, then that doesn't affect the request/response for
the .png file directly (because that response doesn't have a cache-control on
it). I'm only speculating about what your situation looks like here, it's really
two entirely different scenarios: (a) a WebForm producing a dynamic image
with Content-Type: image/png (or other graphics file format), vs. (b) a Web-
Form with a WebControl producing an <IMG SRC="myimage.png"/> tag
where the browser makes a second request that's separate to fetch the image.

One tool that you may try is the power toy, Fiddler, described in this article
and a free download from MSDN,

http://msdn.microsoft.com/ie/default...trofiddler.asp

Check that the browser is receiving the Cache-Control HTTP header on the
request for the image.

Another place to check potentially are the IIS logs which you can usually find in the,

C:\WINDOWS\SYSTEM32\LOGFILES\W3SVC1

directory on the web server. If the request coming in for the image was responded
to with an HTTP Status Code 304, then IIS told the browser that the image
requested hasn't changed (based on its timestamp) and the browser should get
it from its cache.
Derek Harmon
Nov 16 '05 #2
>BUT Still, the image is being extracted from the cache >and the changes
cannot be seen... I don't understand what you are trying to do. Please explain some more. Are
you trying to cache the control or not? Why do you need to uncache on each
client click?

setcachability is being passed the wrong param. you need to pass nocache on
server and client. (don't remember which setting it is off the top of my
head)

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________
"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:9E**********************************@microsof t.com... Hi,

I am new to WebControls, I have created a WebControl that is used to
present
an image, the image bing presented is created on runtime, each client side
button click causes the image to change, this require to prevent this
image
from being cached, I have tried to play around with:
Context.Response.AddHeader("Cache-Control", ... )
and with
Context.Response.Cache.SetCacheability(System.Web. HttpCacheability.NoCache)
BUT Still, the image is being extracted from the cache and the changes
cannot be seen...

What am I doing wrong here?
How can I prevent the image from being cached?

Any help, samples or pointers will be appreciated.

--
Nadav
http://www.sophin.com

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Owatona | last post by:
Hi to all... I have 3 classes derived from webcontrol. I the first i have two dropdownlist, in the second i have some buttons, and the third its the webcontrol that are instanciate the two...
0
by: chris | last post by:
Hi there, I have a webcontrol which should function like a button. Could I add an click action to the webcontrol (like you have ot on a button) or can I add an event handler to the webcontrol? ...
3
by: Mike Owen | last post by:
I have just tried to open a the file "Controls/CreateEditPost.cs" from within Visual Studio .Net, and the error message: 'An error occurred while loading the document. Fix the error, and then...
2
by: Novice | last post by:
I can't seem to get my Custom WebControl to output a button whose click event is associated with a particular method. Here is the code I have right now that contains a panel and there is a...
3
by: spmm# | last post by:
Hi! Could someone please help me with the following; I have a WebControl that basically looks like this: public class LeftMenu : System.Web.UI.WebControls.WebControl { private string...
4
by: Cesar Ronchese | last post by:
Hello. I have a WebForm that contains a Panel object. This panel, at design time is empty. When running, I need to create dinamically a Label and a WebControl (built from the same project). I...
4
by: Christian Hofmann | last post by:
Hello, How is it possible to use a hyperlink webcontrol inside a label webcontrol? I am using resources for globalisation. Now I have a text like this: Please click here to open that...
2
by: Peter Rilling | last post by:
Okay, I something weird is happening where I do not know if I am doing something wrong. I have a page that contains a custom webcontrol that I developed. This webcontrol basically loads a...
2
by: Peregrin | last post by:
Hello world. I will try to explain my problem. I've a webcontrol with an interface which provides a choice of methods. After including the webcontrol in a special aspx page, I want to call an...
2
by: Peter van der veen | last post by:
Hi I want to download files from a webserver. Normally a user goes requsta file, files in the login information and gets an "sava as' dialog. I want to automate this. With the use of a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.