Author Topic: Any way to force an automatic refresh of a browser cache?  (Read 3316 times)

0 Members and 1 Guest are viewing this topic.

Offline DaleReid

  • Forecaster
  • *****
  • Posts: 2002
    • Weather at Eau Claire, WI
Any way to force an automatic refresh of a browser cache?
« on: April 19, 2016, 08:21:41 PM »
Greetings:

I thought I had an answer some time ago, but cannot find it now, or even if it was workable.

I look at a couple web pages, my own, one fed by GraphWeather and another by the late version, need to update to the very last, of Weather Display.

The GraphWeather .jpg that I upload is there, but frequently old, requiring me to hit the Refresh button on my FireFox, which is my current browser of choice for a lot of reasons.

The WeatherDisplay page is similar, with some of the stuff being current, but likely the first graphic being behind, as evidenced by the time stamp on the image, and hitting the refresh icon will get it to display correctly.

My question has several parts.

First, is there a way to tell my browser to not try to load from my cache?  I don't want to clear the whole cache every time I exit the browser since the rest of the stuff seems to be OK, and if I browse other pages, newspapers, etc. I have no problem, so why download all that again (although internet bytes are pretty much a fixed price nowadays).

Second, is there a way to insert some code in the HTML that exists on my web page to force ANY browser that visits the page to do a refresh of that image?

I recollect that years ago, when a progenitor to FireFox was out there (forget the name but it got a lot of competition for IE started), that images on pages really needed to be refreshed when you came back to them after being off line for awhile.

I would assume by now there would be something in HTML ver 5 or whatever, that would tell the browser upon accessing that page to screw what's in the cache and just load a fresh image from the website.  Am I wrong?  This is what I think I had someone tell me about a year or so ago, and I thought I had written down the line of code that basically says to the browser to do that.

Are some browsers better than others at this?  I know the name of the image I refer to does NOT change, but the date and time it was uploaded does.  If the one in local hard drive cache is older and a newer timed one is on the website, it seems logical that the code would grab the new one and display that one.

Very frustrating.  I know Brian H. had a line he displays saying that one might need to force a refresh to get the most current data, so I'm suspecting I'm not the only one running into this problem.

Thanks for any thoughts or ideas.  Obviously I'm not an HTML programmer or I'd know these things and wonder if there is a line of code, how easy is it to insert into my index.html?

Dale
ECWx.info
ECWx.info/graph2.jpg

ECWx.info
&
ECWx.info/t/index.php

Offline Maumelle Weather

  • Forecaster
  • *****
  • Posts: 1824
    • Maumelle Weather
Re: Any way to force an automatic refresh of a browser cache?
« Reply #1 on: April 19, 2016, 08:36:08 PM »
Hi Dale,

Below is a script I came across here somewhere that I use to refresh my satellite and radar pages at different intervals.  The "300" below represents the number of seconds before the script runs to refresh the image.  Where you see "image1", the URL of your image goes there. I normally stick this code just below the image(s) I am refreshing.

What makes this work is where you see"id="reup1" ". This matches the "reup1" in the script below.

<img src="http://radar.weather.gov/Conus/RadarImg/latest.gif" alt="" width="1200" id="reup1"/>

<script type="text/javascript">
       //<![CDATA[
       var t = 300 // Interval in Seconds
       image1 ="http://radar.weather.gov/Conus/RadarImg/latest.gif" //URLs of the Images
       function Start() {
       tmp = new Date();
       tmp = "?"+tmp.getTime()
       document.images["reup1" ].src = image1+tmp
       setTimeout("Start()", t*1000)
                        }
      Start();
      //]]>
  </script>

Hope this helps and didn't confuse,

John
GR2AE, GR3, Cumulus

Offline DaleReid

  • Forecaster
  • *****
  • Posts: 2002
    • Weather at Eau Claire, WI
Re: Any way to force an automatic refresh of a browser cache?
« Reply #2 on: April 19, 2016, 09:30:44 PM »
Thank you John,
I am learning, slowly, how some of these things work.

If I understand, this will refresh the pages displayed at the interval specified, but not right away upon first opening the page?

And then at the interval you've specified, it then refreshes again?  At least as I look at it, but I don't know the intricacies of the language yet to know if I'm right.

Off to study some more.  Dale
ECWx.info
&
ECWx.info/t/index.php

Offline miraculon

  • Sunrise Side Weather
  • Forecaster
  • *****
  • Posts: 4107
  • KE8DAF
    • Sunrise Side Weather in Rogers City MI USA
Re: Any way to force an automatic refresh of a browser cache?
« Reply #3 on: April 20, 2016, 08:19:38 AM »
Quote
I recollect that years ago, when a progenitor to FireFox was out there (forget the name but it got a lot of competition for IE started)

Are you thinking about Netscape?



It was Firefox's ancestor. Then the granddaddy of them all is NCSA Mosaic.

Greg H.


Blitzortung Stations #706 and #1682
CoCoRaHS: MI-PI-1
CWOP: CW4114 and KE8DAF-13
WU: KMIROGER7
Amateur Radio Callsign: KE8DAF

Offline AWL

  • Forecaster
  • *****
  • Posts: 727
    • Ardmore Weather Live
Re: Any way to force an automatic refresh of a browser cache?
« Reply #4 on: April 20, 2016, 08:30:50 AM »
Thank you John,
I am learning, slowly, how some of these things work.

If I understand, this will refresh the pages displayed at the interval specified, but not right away upon first opening the page?

And then at the interval you've specified, it then refreshes again?  At least as I look at it, but I don't know the intricacies of the language yet to know if I'm right.

Off to study some more.  Dale

The code John posted will auto-refresh a specific image, not the entire page. I use a similar code for my radar images also.

Doug

Offline DaleReid

  • Forecaster
  • *****
  • Posts: 2002
    • Weather at Eau Claire, WI
Re: Any way to force an automatic refresh of a browser cache?
« Reply #5 on: April 20, 2016, 09:07:39 AM »
Doug, and John,

I told you I am barely crawling when it comes to code. I didn't understand it yet. That was the question I was going to ask after thinking about it last night.
Perfect!  Thank you very much.

Oh, Greg, that was it, Netscape.  I used my 2400 baud modem to download each new release and then quick share it amongst friends so we didn't all have to pray our phone line wouldn't hiccough part way through the downloads for each computer.

Oh, how far we've come....

ECWx.info
&
ECWx.info/t/index.php

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: Any way to force an automatic refresh of a browser cache?
« Reply #6 on: April 20, 2016, 10:59:28 AM »
Dale, how about a JavaScript that will refresh a complete page while displaying the time remaining until the page refreshes in the document's title bar?

If such a script could help, have a look at the "Auto refresh page with timer" script.
R_o_B
---
eMail: weather@herray.net

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Any way to force an automatic refresh of a browser cache?
« Reply #7 on: April 20, 2016, 11:16:34 AM »
Im not sure if it is the best idea to reload the whole page. You can use ajax, or the method outlined above, to just update an image or div element. Why would you want to reload the whole site

 

anything