Author Topic: Caching  (Read 1502 times)

0 Members and 1 Guest are viewing this topic.

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Caching
« on: September 26, 2015, 07:27:39 PM »
I was just wondering, is there any way to force the browser not to cache certain image? In particular, I have a banner here on the forum, but the problem is that it is cached and the link in my signature obviously stays the same, so unless I refresh the page, when browsing the forum I see values several days old

Offline Cutty Sark Sailor

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 3394
    • Frankfort Weather - TwinHollies WeatherCenter
Re: Caching
« Reply #1 on: September 27, 2015, 06:30:26 AM »
Don't think so.. :twisted:
 but, despite caching, you can force the browser to load most recent image.
<img src="http://ourspecial.net/twinhollies/weathercenter/banr/wxgraphic.php?type=banner_big" alt="current Frankfort conditions"/>
the secret is the ?
as in the below sig...
« Last Edit: September 27, 2015, 06:57:37 AM by Cutty Sark Sailor »
 


Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Caching
« Reply #2 on: September 27, 2015, 07:00:39 AM »
Hi,  I'm afraid that is not a solution because mine has a PHP parameter as well

Offline weatherc

  • Senior Contributor
  • ****
  • Posts: 278
Re: Caching
« Reply #3 on: September 27, 2015, 09:57:16 AM »
Yes there are, even a few ways:

- Set image expirestime to something like 2000-01-01.
- If the image are shown with PHP, add a timestamp argument to the url like: image.png?<?php echo time(); ?>. This way are pretty flexible because its possible to control with the timestamp for how long its possible cached, like instead of time() use date("YmdH") what should force a new image at least once a hour.
- If one have access to the server itself (like Nginx) are there even more possibilities like setting expirestime to 6 hours after image has been updated. I use this for all my EWN and EB maps.

 

anything