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 (HttpCacheabili ty.NoCache)
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********@hotm ail.com http://www.nathansokalski.com/ 7 1958
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.EventArg s) Handles MyBase.Load
Response.Cache. SetExpires(Date Time.Now.AddTic ks(500))
Dim myForeBrush As Brush = Brushes.Black
Dim myFont As New Font("Times New Roman", 8, FontStyle.Regul ar)
Dim textHeight As Single
Dim bm As New Bitmap(120, 20)
Dim g As Graphics = Graphics.FromIm age(bm)
g.Clear(Color.W hite)
Dim textSize As SizeF = g.MeasureString (now.tostring, myFont)
g.DrawString(No w.ToString, myFont, myForeBrush, _
New RectangleF(0, 0, 120, 20))
Dim ms As New IO.MemoryStream
Dim arrImage() As Byte
bm.Save(ms, Imaging.ImageFo rmat.Bmp)
arrImage = ms.GetBuffer
Response.Binary Write(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********@hot mail.com> wrote in message
news:#Q******** ******@TK2MSFTN GP15.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 (HttpCacheabili ty.NoCache)
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********@hotm ail.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******** ******@TK2MSFTN GP14.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.EventArg s) Handles MyBase.Load Response.Cache. SetExpires(Date Time.Now.AddTic ks(500)) Dim myForeBrush As Brush = Brushes.Black Dim myFont As New Font("Times New Roman", 8, FontStyle.Regul ar) Dim textHeight As Single Dim bm As New Bitmap(120, 20) Dim g As Graphics = Graphics.FromIm age(bm) g.Clear(Color.W hite) Dim textSize As SizeF = g.MeasureString (now.tostring, myFont) g.DrawString(No w.ToString, myFont, myForeBrush, _ New RectangleF(0, 0, 120, 20)) Dim ms As New IO.MemoryStream Dim arrImage() As Byte bm.Save(ms, Imaging.ImageFo rmat.Bmp) arrImage = ms.GetBuffer Response.Binary Write(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.d e
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********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.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 (HttpCacheabili ty.NoCache)
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********@hotm ail.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 caching. This means that the class itself can
serve up a scaled version of itself and use some basic caching to avoid
having to perform the scaling...
|
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, causing the cache-hit-ratio to
dramatically decrease, since fetching a couple of binaries from the
image-column uses up the
|
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 streamed, but just linked in HTML
output).
The problem is, when user want to see the graph by changing parameters, they
always have to click refresh to...
|
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 upload to the folder 'Images' and newly
selected image would overwrite existing image 'Logo.jpg'. (Image name
remains same and image changes). The image...
|
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 url effectively limit
client-side image caching to the lifetime of the session?
Thanks
Jake
| |
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 the same name. When they are
cached, the cached image is displayed which is not what I want. I thought
that using...
|
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 changes (like a "plus" becomes
a "minus" when a folder icon is expanded) is does a
document.all.src="picsV/minus.gif"
which I am pretty sure goes...
|
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", and an option for the user to update the
photo. If they click the update button, I then flip up a new panel, where I
have a FileUpload control and...
|
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, say DIV, and refresh DIV every 10 seconds, background image
is reguested every 10 seconds for IE6, too.
The fix which I found did not fix the...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |