473,385 Members | 1,642 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,385 software developers and data experts.

Forcing a browser to re-render an image from its URL location andnot from the browser's cache

Is there a way in Javascript, or perhaps in HTML, to force a browser to
re-render an image on an HTML page after a round-trip between the client
and the server ?

In my particular case, the image is changing on the server although the
URL for it remains the same, but the browser is still displaying the old
image from its cache rather than the new image from its URL location.
Oct 23 '07 #1
8 4034
Edward Diener <di***********************@bellsouth.netwrote in
news:3I****************@bignews1.bellsouth.net:
Is there a way in Javascript, or perhaps in HTML, to force a browser to
re-render an image on an HTML page after a round-trip between the client
and the server ?

In my particular case, the image is changing on the server although the
URL for it remains the same, but the browser is still displaying the old
image from its cache rather than the new image from its URL location.
you can try appending fake arguments to the URL, ie:

<img src="naked.jpg?blahblah" />

Oct 23 '07 #2
Good Man wrote:
Edward Diener <di***********************@bellsouth.netwrote in
news:3I****************@bignews1.bellsouth.net:
>Is there a way in Javascript, or perhaps in HTML, to force a browser to
re-render an image on an HTML page after a round-trip between the client
and the server ?

In my particular case, the image is changing on the server although the
URL for it remains the same, but the browser is still displaying the old
image from its cache rather than the new image from its URL location.

you can try appending fake arguments to the URL, ie:

<img src="naked.jpg?blahblah" />
Thanks, but that does not work.

Is it not a bug in a browser if the browser never re-renders an image
except from its cache, or is that just the way certain browsers work ?

If certain browsers work that way surely there must be some way to tell
a browser to re-render the image because the image has changed between
the trip between the client and server and back. Do all modern browsers
just assume that an image in an HTML page must remain static and never
change once it is displayed during a session, and strictly rely on the
end-user to tell the browser to refresh the entire HTML page when
necessary through some sort of menu command ?
Oct 23 '07 #3
Friedemann Kiersch wrote:
>>you can try appending fake arguments to the URL, ie:
<img src="naked.jpg?blahblah" />
Thanks, but that does not work.

Actually, it _does_ work if you apply a random
number/string as the fake argument, changing its
value on _every_ page impression.
It does also work with cache control headers, which don't fill the cache
which garbage, and don't reduce access speed to other resources, effectively.

http://www.mnot.net/cache_docs/
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Oct 23 '07 #4
Thomas 'PointedEars' Lahn wrote:
Friedemann Kiersch wrote:
>>>you can try appending fake arguments to the URL, ie:
<img src="naked.jpg?blahblah" />

Thanks, but that does not work.
Actually, it _does_ work if you apply a random
number/string as the fake argument, changing its
value on _every_ page impression.

It does also work with cache control headers, which don't fill the cache
which garbage, and don't reduce access speed to other resources, effectively.

http://www.mnot.net/cache_docs/
PointedEars
We are using the HTML below, to no effect. The actual problem is an
image URL being displayed on an HTML page using IE7.

<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1985 00:00:01 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="cache-control" CONTENT="no-cache, no-store,
must-revalidate">
<html xmlns="http://www.w3.org/1999/xhtml">

The actual image, to which the URL points, is being changed between
client-server roundtrips, but even with the HTML code above for the HTML
page, IE7 just refuses to re-render the image but insists on always
grabbing it from its cache and therefore not displaying the updated image.
Oct 24 '07 #5
Edward Diener wrote:
Friedemann Kiersch wrote:
>>>you can try appending fake arguments to the URL, ie:
<img src="naked.jpg?blahblah" />

Thanks, but that does not work.
Actually, it _does_ work if you apply a random
number/string as the fake argument, changing its
value on _every_ page impression.

Perhaps in your case this works but in my case it does not.

Are you saying that the argument string after the URL
It is _not_ after the URL/URI, but (the query) part of it. See RFC3986.
has to be a numeric string to work as opposed to just any random string ?
More, `blahblah' (the query part) in this example should contain a value
that is unique over time.

With client-side JS/ES,

(new Date()).getTime()

or (slightly more efficient)

(new Date()).valueOf()

provide that. Just in case you find no way with your server to send cache
control headers or you find your currently unknown target UA ignoring them
(keep in mind that not all UAs support HTTP/1.1, so you should send the
cache control headers defined in HTTP/1.0, too).
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Oct 24 '07 #6
Edward Diener wrote:
[...]
Ok, thanks for the heads-up about using actual cache control headers
rather than meta elements. I am using an NSAPI based C++ web server
environment ( in my job ) and I will now try to figure out how to
generate the correct cache control headers when sending a page back to
the client.
Even with correctly configured headers, you have no iron guarantee
that every visiting browser (or server, or any in between gateways)
will obey the rules. For example, ISPs looooove to buffer because it
can save them a lot of money on traffic. I would take one of the
suggested randomizers for maximum result.

--
Bart

Oct 25 '07 #7
Bart Van der Donck wrote:
Edward Diener wrote:
>[...]
Ok, thanks for the heads-up about using actual cache control headers
rather than meta elements. I am using an NSAPI based C++ web server
environment ( in my job ) and I will now try to figure out how to
generate the correct cache control headers when sending a page back to
the client.

Even with correctly configured headers, you have no iron guarantee
that every visiting browser (or server, or any in between gateways)
will obey the rules. For example, ISPs looooove to buffer because it
can save them a lot of money on traffic. I would take one of the
suggested randomizers for maximum result.
Unforunately neither using the correct cache control headers nor using
the randomizer technique is working in my case. The only thing left to
try is to randomly generate an entirely different image src name for
each round-trip.
Oct 25 '07 #8
[Sorry for posting out of thread but this FUD has to be corrected.]
Bart Van der Donck wrote:
>Edward Diener wrote:
>>[...]
Ok, thanks for the heads-up about using actual cache control headers
rather than meta elements. I am using an NSAPI based C++ web server
environment ( in my job ) and I will now try to figure out how to
generate the correct cache control headers when sending a page back to
the client.
Even with correctly configured headers, you have no iron guarantee
that every visiting browser
True. The client will have to support at least HTTP/1.0. However,
HTTP/0.9-only clients are a rare commodity nowadays.
>(or server, or any in between gateways) will obey the rules.
The server does not have to obey the rules, but the client has to. The
gateway would have to work at the application level to recognize and
filter out HTTP headers. No gateway that works at the application level
will do the latter.
>For example, ISPs looooove to buffer because it can save them a lot
of money on traffic.
Those ISPs will become bankrupt soon because no customer likes it if their
Reload button does not work at all. Proxy caches as employed by ISPs cache
Web data based on the full URI, so the case you describe here is not at all
realistic.
PointedEars
Oct 25 '07 #9

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

Similar topics

0
by: Hugh Lutley | last post by:
I'm trying to install the Device::SerialPort module using CPAN but whilst CPAN is running 'make test' a couple of errors are flagging so I cannot continue the install without forcing it. I'm not...
12
by: Ritz, Bruno | last post by:
hi in java i found that when a method has a throws clause in the definition, callers must either handle the exceptions thrown by the method they are calling or "forward" the exception to the...
1
by: John M | last post by:
Hello All, The code below is something I have been working on and just can't get past. I know it must be very simple but here goes. The Form Method line text is invisible on browers, but still...
6
by: Finn Newick | last post by:
By defining a style as follows: @media aural, handheld {td.layout {display:block;}} I'm hoping to linearise layout tables when viewed by screenreaders and handheld devices (it is also be in...
40
by: Neo The One | last post by:
I think C# is forcing us to write more code by enforcing a rule that can be summarized as 'A local variable must be assgined *explicitly* before reading its value.' If you are interested in what...
12
by: Howard Kaikow | last post by:
In the code below, ALL the lines that start with PPTfile << are getting the following error at build time. "//i:\C++\C++Code\FileOperations\Form1.h(127) : warning C4800: 'System::String __gc *'...
0
by: steve | last post by:
SysInternals provides a *FANTASTIC* product called DebugView. It allows you to snoop User and Kernel traces, eg. You can view Trace.WriteLine etc It also timestamps the traces. I deal a lot with...
2
by: Scott | last post by:
Are there any div attributes that could force a div element to stay in the background? I have a .vbs calendar class that opens a small calendar. Unfortunately, sometimes it opens above a form...
3
by: eross | last post by:
Noob here, I am trying to manage calls from multiple clients to my web service by only letting one execute at a time and forcing the others to wait. Code is as follows: ...
4
by: teeBull | last post by:
Hi all, We'd like to take advantage of code we already have for transforming XML into HTML (using XSLT) for our users to save the HTML as an MS Word document locally. I've dug around and found...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.