Hi all,
I have an application which generates image graphs. These cache nicely
at the client, however if the user submits more data, I'd like to
force a reload of the image from the server.
I had a google, but all I could find were suggestions to use a varying
query in the URL. This is not a solution to my problem because if I
change the page to do that then ALL the graphs will be reloaded every
time.
I tried
document.getEle mentById("imgs_ id_tag").src.re load():
and
document.getEle mentById("imgs_ id_tag").reload ():
But just got errors.
(If I open JUST the image URL in a browser, I get the cached version,
if I then click on refresh, it goes back to the server to get a new
copy - which is what I want).
Any suggestions?
TIA
C.
Jul 18 '08
32 3149
Jorge wrote:
Thomas 'PointedEars' Lahn wrote:
>Jorge wrote:
>>Thomas 'PointedEars' Lahn wrote: Cache-controlling HTTP headers are the correct approach instead. Right. Cache-control headers ought to be explicitly setup just for these images. Agreed. But the OP was looking for a client-side solution, and that's not.
| I have an application which generates image graphs. These cache nicely | at the client, however if the user submits more data, I'd like to | force a reload of the image from the server.
Not a single word about a client-side only solution.
Does this look like server-side scripting to you : (?)
"I tried document.getEle mentById("imgs_ id_tag").src.re load(): "
"and document.getEle mentById("imgs_ id_tag").reload (): "
I have noticed that before. So the OP had a problem with their client-side
script for refreshing the image. That does not mean in any way that the
solution must be client-side only.
>(...) ISTM anything else would require a server-push communication like Comet.
Duh !
Tough luck.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
On Jul 19, 10:44*am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
Jorge wrote:
Thomas 'PointedEars' Lahn wrote:
Jorge wrote: Thomas 'PointedEars' Lahn wrote: Cache-controlling HTTP headers are the correct approach instead. Right. Cache-control headers ought to be explicitly setup just for these images. Agreed. But the OP was looking for a client-side solution, and that's not.
| I have an application which generates image graphs. These cache nicely
| at the client, however if the user submits more data, I'd like to
| force a reload of the image from the server.
Not a single word about a client-side only solution.
Does this look like server-side scripting to you : (?)
"I tried document.getEle mentById("imgs_ id_tag").src.re load(): "
"and document.getEle mentById("imgs_ id_tag").reload (): "
I have noticed that before. *So the OP had a problem with their client-side
script for refreshing the image. *That does not mean in any way that the
solution must be client-side only.
(...)
ISTM anything else would require a server-push communication
like Comet.
Thanks guys - unfortunately it doesn't really solve my proble - I
guess I didn't make it clear enough.
I really want the image to be cached client side unless the data used
to create the image (server-side) changes. I can't really get every
client who has a cached copy to update their cache. Using a dirrent
URI each time by appending a random value just makes the browser think
it is a different image - undermining the caching which is working
fine in most cases:
had a google, but all I could find were suggestions to use a varying
query in the URL. This is not a solution to my problem because if I
change the page to do that then ALL the graphs will be reloaded every
time.
However, I think it may be possible to do for the client who just
uploaded the data - since, if they click the 'Refresh' button in the
browser it carries out an unconditional reload of the content. I'm
wanting to emulate this from Javascript.
C.
C. ( http://symcbean.blogspot.com/) wrote:
I really want the image to be cached client side unless the data used to
create the image (server-side) changes.
That is what cache-controlling headers are for: <http://mnot.net/cache-docs>
I can't really get every client who has a cached copy to update their
cache.
Why not?
Using a dirrent URI each time by appending a random value just makes the
browser think it is a different image - undermining the caching which is
working fine in most cases:
This is updating the cache in a sense, only that it is filled with mostly
useless information then. You hardly want that.
>had a google, but all I could find were suggestions to use a varying query in the URL. This is not a solution to my problem because if I change the page to do that then ALL the graphs will be reloaded every time.
However, I think it may be possible to do for the client who just
uploaded the data - since, if they click the 'Refresh' button in the
browser it carries out an unconditional reload of the content. I'm
wanting to emulate this from Javascript.
Have you already tried executing
img.src = img.src;
or
var oldsrc = img.src;
img.src = "";
img.src = oldsrc;
in a repetitive setTimeout() while using cache-controlling headers?
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
In comp.lang.javas cript message <29d0c3f4-9a1e-4301-81b6-6dc5da5436b9@y3
8g2000hsy.googl egroups.com>, Fri, 18 Jul 2008 12:16:30, Jorge
<jo***@jorgecha morro.composted :
>On Jul 18, 7:50*pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de> wrote:
>> Also, a random value alone is not sufficient; Yes it is, Thomas, remember that the OP said that he wanted to reload the image *once*.
>it must be a value that is unique over a longer period of time, like the timestamp that you suggested. The probability of obtaining the same ramdom number twice in a row is about 1/(2^(8*8)) === 1/184467440737095 51615 And keeps being almost null even after tens or hundreds of extractions.
No, for two reasons. The generator is not necessarily 64-bit or even
53-bit. In my js-randm.htm, "MSIE 6 and 7 show 53 bits; Firefox 2.0.0.3
shows 52 bits; Opera 9.21 shows 31 bits; Safari 3.1 shows 31 bits."
And, as the generator is only pseudo-random, it should not repeat until
after a full cycle.
What does that page report (for various browsers?) on your Mac?
--
(c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demo n.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
In comp.lang.javas cript message <48************ **@PointedEars. de>, Fri,
18 Jul 2008 19:50:07, Thomas 'PointedEars' Lahn <Po*********@we b.de>
posted:
>
>elem.src = oldSrc + '?rnd=' + new Date().getTime( );
This basically says "set the src to the exact same thing, with an aditional 'random' parameter (current date/time as a number)"
>Also, a random value alone is not sufficient; it must be a value that is unique over a longer period of time, like the timestamp that you suggested.
In most browser instances, Math.random can be shown to give 53 bits of
pseudo-randomness, although the initial value's randomness depends on
the quality of the initialisation.
Machines connected to the Internet generally resynchronise from time to
time with an Internet or server clock. Nearly 50% of computers will
need to be set back in time, and in the case of those which cannot be
slowed or stopped but must jump back it will be necessary to repeat a
certain amount of internal-clock time. So new Date().getTime( ) may
give the same value after an interval as it did before. That will not
often happen, but ISTM likely to happen more often than the repeat of a
good RNG, let alone of a a PRNG which will cycle through all possible
values before repeating.
Recommending adjusting HTTP headers as opposed to adjusting the 'URL' is
not helpful to those whose servers do not allow header control.
Professional servers should allow it; those available to many of the
amateurs who read this group may very well not do so.
>Please do a little research before you post something here.
Please think before you post something here.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demo n.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
On Jul 19, 6:07*pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
>
No, for two reasons. *The generator is not necessarily 64-bit or even
53-bit. *In my js-randm.htm, "MSIE 6 and 7 show 53 bits; Firefox 2.0.0.3
shows 52 bits; Opera 9.21 shows 31 bits; Safari 3.1 shows 31 bits."
And, as the generator is only pseudo-random, it should not repeat until
after a full cycle.
Yes you're right. In fact Safari's PRNG always repeats at n=
2,147,483,645 (-2^31) (don't tell Thomas :-)
What does that page report (for various browsers?) on your Mac?
"Apparent resolution is at least 30 bits."
Thanks,
--Jorge.
On Jul 19, 6:07*pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
>
What does that page report (for various browsers?) on your Mac?
On a Mac :
Webkit r34974: "Apparent resolution is at least 30 bits."
Safari 3.1.2: "Apparent resolution is at least 30 bits."
Opera 9.51: "Apparent resolution is at least 31 bits."
Navigator 9.0.0.3: "Apparent resolution is at least 52 bits."
Camino 1.6.1: "Apparent resolution is at least 52 bits."
FF 2.0.0.16: "Apparent resolution is at least 52 bits."
FF 3.1: "Apparent resolution is at least 52 bits."
IE 5.2: "Apparent resolution is at least 53 bits."
iCab 3.0.5 : "Apparent resolution is at least 58 bits."
--Jorge
On Jul 19, 6:07 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
What does that page report (for various browsers?) on your Mac?
On a Mac :
Webkit r34974: "Apparent resolution is at least 30 bits."
Safari 3.1.2: "Apparent resolution is at least 30 bits."
Opera 9.51: "Apparent resolution is at least 31 bits."
Navigator 9.0.0.3: "Apparent resolution is at least 52 bits."
Camino 1.6.1: "Apparent resolution is at least 52 bits."
FF 2.0.0.16: "Apparent resolution is at least 52 bits."
FF 3.1: "Apparent resolution is at least 52 bits."
IE 5.2.3: "Apparent resolution is at least 53 bits."
iCab 3.0.5: "Apparent resolution is at least 58 bits."
--Jorge
In comp.lang.javas cript message <c9681dae-4958-410e-993b-86bb9eeddd00@l4
2g2000hsc.googl egroups.com>, Sat, 19 Jul 2008 12:37:21, Jorge
<jo***@jorgecha morro.composted :
>On Jul 19, 6:07 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
>What does that page report (for various browsers?) on your Mac?
...
>iCab 3.0.5: "Apparent resolution is at least 58 bits."
That one was initially rather unexpected, since Math.random() is
supposed to return an evenly-distributed IEEE Double with an effective
53-bit mantissa, and the best previously seen or reported was 53 bits.
ISO/IEC 16262 only requires that the result of Math.random() be evenly
distributed, not that the resolution be independent of the value.
It appears that other browsers in effect mask the output of the
(64-bit?) PRNG to 53 bits before converting to Double, while iCab does
that only within the conversion itself.
It seems undesirable for there to be unnecessary numerical differences
between browsers; if anyone has contact with those writing future
specifications, then I suggest that they ask for the future spec to have
this uncertainty removed. While iCab in a sense has better randomness,
ISTM that uniformity would be preferable.
The function you observed, Resol, is now Resol1; new Resol3 is similar
but uses only randoms >= 0.5.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
On Jul 20, 7:32*pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
>
The function you observed, Resol, is now Resol1; new Resol3 is similar
but uses only randoms >= 0.5.
John,
I have retouched your resol1() a little bit. Now it receives a
parameter p, and it doesn't return until the higher resolution found
remains unchanged for p iterations of the loop. It gives higher
readings now.
I have also written a bits() function that finds what is the smaller
power of 2 for which it's true that (2^x) === ((2^x)+1). I think that
that must be the size of the mantissa, or not ?
See it here : http://tinyurl.com/68d9br
These are the numbers I get :
IE 5.2.3 : 53, 53.
FF2, FF3 : 52, 53.
Safari : 30, 53.
Opera 9.51 : 31, 53.
iCab 3.0.5 : 63, 53.
But I don't understand why those numbers are different. And, if the
mantissa is 53 bits (iCab), how can, why does resol1() give 63 ?
Here's the code :
<script>
window.onload= function () {
var resol1= (function (p) {
var x, t, max= 0, i= p;
while (i) {
t= 0, x= Math.random();
while ((x*= 2)%1 0) { // shift left until empty
t++;
}
if (t max) {
max= t, i= p;
} else {
i--;
}
}
return max;
})(1e4);
var bits= (function () {
var x, i= 0;
do {
x= Math.pow(2,++i) ;
} while (x !== (x+1))
return i;
})();
var test= Math.pow(2,bits );
var text= "resol1() : Maximum resolution is at least "+resol1+"
bits.<br>";
text+= "bits() : "+bits+" -In this browser "+(test+1)+ " ===
1+"+test;
(document.body. appendChild(
document.create Element(
'h2'))).innerHT ML= text;
};
</script>
Thanks,
--Jorge. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dogeater |
last post by:
I've done hours of research but I can't seem to find an answer to a
very simple problem.
I have a catalog site where a user can upload an image for a certain
product. He/she edits the product by uploading a different image.
The problem is that the image is being cached and it doesn't get
refreshed unless a user manually refreshes his/her browser.
I've tried HTTP headers, Meta tags, htaccess and javascript. How are
you guys doing...
|
by: jeff |
last post by:
Hello,
I'm building an internal web application using HTML/PHP/Javascript.
The system is flexible to the point where the user can have as many
browser windows open for each part of the system.
I would like a browser window that has just gained the focus to
refresh. Is this possible and how?
Thanks,
|
by: DraguVaso |
last post by:
Hi,
I have a Windows Service running (made in VB.NET), and wanted to be able to
change from time to time some parameters by changing them in the App.config.
But it seems that the application doesn't use the changed values in the
App.config, but continue to use the values that were there during start-up.
Is there a way to let the application use the new values in the App.config?
Is there kind of some 'refresh' function that I should...
|
by: Lex |
last post by:
I want to reload a page only once. Therefor meta refresh is not
suitable, because then it refreshes every x seconds. Is there a
possibility to refresh only once?
regards,
Lex Ouburg
|
by: cosmic foo |
last post by:
I have a page with about 100 images of about 10k each.
where a typical img tag looks like this,
<img src="item001.jpg" height="70" alt="" onMouseOver="showPic(this)"
border="0">
Not all the images need to be viewed at once, depending on what category is
selected, only about 10 images are seen at any one time.
I hide and show categories of images by setting a div container
display:none/block or visibility:hidden/visible.
Even though the...
| |
by: Paul Johnson |
last post by:
I have a web site that allows users to upload images. The problem is when
an image is uploaded over the top of another image the user would have to
press F5 to refresh the images and clear the cashe. Is there anyway I can
automatically make the image refresh?
If that is not possible is there a way of making the whole page refresh
automatically?
|
by: David |
last post by:
Hello.
I have such problem:
I have ImageButton on my form which is attached to some image like
"image.jpg", now when I change image file (physically file) with some other
file with the same name my page shows the old image until I click "Refresh"
button of the browser.
So how can I refresh web form from code?
Or may be there is some other way to solve this problem?
|
by: Just D. |
last post by:
All,
How should we refresh the current aspx frame? I disabled caching using this
command on Page_Load():
Response.Cache.SetCacheability(HttpCacheability.NoCache);
but it didn't help.
The problem is that this page shows the client Logo image, then asks to
upload a new one if required, finally it should show the uploaded picture.
The problem is that it doesn't. If I press F5, then I can see the updated
|
by: nuhura01 |
last post by:
Hi..
I have a button to preview image using the following code, which
preview the image in html page:
Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |