I have been trying to find a way to prevent the images on my site from being
cached on the user's machine. I want to avoid this because the images used
in an Image control often change, yet have the same name. When they are
cached, the cached image is displayed which is not what I want. I thought
that using
Response.Cache.SetCacheability(HttpCacheability.No Cache)
would have achieved this, but it seems to only prevent the .aspx file from
being cached. Is there any way to prevent images from being cached as well?
--
Nathan Sokalski nj********@hotmail.com http://www.nathansokalski.com/ 7 1943
Nathan,
I am not sure if this will do it (I did not try it). In this sample I make
the image in the procedure, however you can do it of course using a read.
Now you can get the image by its page url
\\\
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Response.Cache.SetExpires(DateTime.Now.AddTicks(50 0))
Dim myForeBrush As Brush = Brushes.Black
Dim myFont As New Font("Times New Roman", 8, FontStyle.Regular)
Dim textHeight As Single
Dim bm As New Bitmap(120, 20)
Dim g As Graphics = Graphics.FromImage(bm)
g.Clear(Color.White)
Dim textSize As SizeF = g.MeasureString(now.tostring, myFont)
g.DrawString(Now.ToString, myFont, myForeBrush, _
New RectangleF(0, 0, 120, 20))
Dim ms As New IO.MemoryStream
Dim arrImage() As Byte
bm.Save(ms, Imaging.ImageFormat.Bmp)
arrImage = ms.GetBuffer
Response.BinaryWrite(arrImage)
g.dispose
End Sub
///
I hope this helps,
Cor
I don't think it is caching. Check that the new image on the server has a
later create date than the older, if not the older will be shown.
Test this by having 2 images, aaa.jpg, put the one with the older creation
date on the server and browse to it, now put the newer one on the server,
browse to it and the 2nd one will show, all OK.
Now rename them to bbb.jpg, first put the one with the newer creation date
on the server, browse, now the older creation date, browse, the 1st image
still shows up.
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:#Q**************@TK2MSFTNGP15.phx.gbl... I have been trying to find a way to prevent the images on my site from
being cached on the user's machine. I want to avoid this because the images used in an Image control often change, yet have the same name. When they are cached, the cached image is displayed which is not what I want. I thought that using Response.Cache.SetCacheability(HttpCacheability.No Cache)
would have achieved this, but it seems to only prevent the .aspx file from being cached. Is there any way to prevent images from being cached as
well? -- Nathan Sokalski nj********@hotmail.com http://www.nathansokalski.com/
I agree with Chris - but if you want to make sure this doesn't happen, use a
HTTPHandler to draw your own images - then they can't steal your bandwidth
either ;-) http://www.uberasp.net/GetArticle.aspx?id=13
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:eE**************@TK2MSFTNGP14.phx.gbl... Nathan,
I am not sure if this will do it (I did not try it). In this sample I make the image in the procedure, however you can do it of course using a read. Now you can get the image by its page url
\\\ Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Response.Cache.SetExpires(DateTime.Now.AddTicks(50 0)) Dim myForeBrush As Brush = Brushes.Black Dim myFont As New Font("Times New Roman", 8, FontStyle.Regular) Dim textHeight As Single Dim bm As New Bitmap(120, 20) Dim g As Graphics = Graphics.FromImage(bm) g.Clear(Color.White) Dim textSize As SizeF = g.MeasureString(now.tostring, myFont) g.DrawString(Now.ToString, myFont, myForeBrush, _ New RectangleF(0, 0, 120, 20)) Dim ms As New IO.MemoryStream Dim arrImage() As Byte bm.Save(ms, Imaging.ImageFormat.Bmp) arrImage = ms.GetBuffer Response.BinaryWrite(arrImage) g.dispose End Sub ///
I hope this helps,
Cor
Well what you can also do is when generating the URL for the image,
append a random string to it like this:
image.ImageUrl = "someimage.gif?randomstring"
and then the browser will get the fresh image as long as the
randomstring is different. For random string you can use TickCount or
anything else you want. Of course there are some drawbacks to this
technique (such as brwoser getting image even though it hasn't changed).
L
Chris Botha wrote: I don't think it is caching.
Think again. If an image is being cached on the client-side or some
downstream proxy, you can change it on the server-side all day long
without affecting the client.
You *must* specify the appropriate Cache-Control header
("must-revalidate" in theory, thanks to IE "no-cache" in practice) to
force clients and proxies to send conditional GETs and pick up
server-side updates.
Cheers,
-- http://www.joergjooss.de
mailto:ne********@joergjooss.de
You can configure this in IIS MMC by navigating to the folder containing the
images and adjusting the HTTP Headers to either "expire immediately" or
"never expire".
--
Benjamin Strackany http://www.developmentnow.com
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... I have been trying to find a way to prevent the images on my site from
being cached on the user's machine. I want to avoid this because the images used in an Image control often change, yet have the same name. When they are cached, the cached image is displayed which is not what I want. I thought that using Response.Cache.SetCacheability(HttpCacheability.No Cache)
would have achieved this, but it seems to only prevent the .aspx file from being cached. Is there any way to prevent images from being cached as
well? -- Nathan Sokalski nj********@hotmail.com http://www.nathansokalski.com/
Bill, I agree with Chris - but if you want to make sure this doesn't happen, use a HTTPHandler to draw your own images - then they can't steal your bandwidth either ;-)
I had the idea that that is what I am doing in my sample
:-)
The bitmap is embedded in the url by the and sent as bitmap by the redirect.
It is not a reference to an image url.
However if you disagree that with me, please tell where I make a mistake in
that idea?
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fred |
last post by:
Hello
As mentioned in another post, I'm in the process of extending an existing
class.
One of the things I'm trying to achieve is an improvement in performance
through the use of some image...
|
by: Marwin |
last post by:
Hi all,
I have a database with 40GB of binary objects stored in image columns
in two tables.
Our database server is also used for another 15 databases.
SQL Server caches the image-column,...
|
by: Mike Sobeiski |
last post by:
Hi There!
I'm developing a web project that requires to produce charts off the
database and output it as image and presented to the user in a HTML
document. (NOTE: Image is not directly...
|
by: Suraj Joneja |
last post by:
Hi All,
I've an image control on my ASP.net page. This displays an image named
'Logo.jpg' in the location '~\Images'. Another application can change this
image. It can select any image and...
|
by: Jake |
last post by:
Does cookieless session state (with the sessionid embedded into the url)
interfere with the browser's retrieval of cached images from one session to
the next? Does the sessionid embedded into the...
|
by: Nathan Sokalski |
last post by:
I have been trying to find a way to prevent the images on my site from being
cached on the user's machine. I want to avoid this because the images used
in an Image control often change, yet have...
|
by: Giggle Girl |
last post by:
Hello,
I am helping to design a web application that uses 167 little icons on
various pages in a framed environment. As is, the app loads each icon
on a page by page basis, and if an image...
|
by: Mark Denardo |
last post by:
This is related to another post I submitted, but I'll be more precise this
time.
I have a web page that contains an Image webcontrol that loads its image by:
Image1.ImageUrl="<username>.jpg",...
|
by: vunet.us |
last post by:
Hi,
I found a bug in IE6, though it is known already. If I have a CSS
background property set to some image, such as
background:url(myimg.gif);, and I apply this property to some html
element,...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |