Newton Ferrers and Noss Mayo weather
Newton Ferrers and Noss Mayo
Home : Weather : Tides : About : Contact
 


.
 Weather Tech
 
BBC Video Forecast
Spotlight News/Weather
Met Office Local Forecast
Met Office Shipping Forecast
 

Weather Tech

This tech. section is for users of WD (WeatherDisplay), weather web site developers & webmasters. Click here for our weather section!

 

PHP Image No Cache

OK so you have a great graphic design for your web pages, and photos and so on. You want them to be cached in your user's browser as they never change, and you want to save data transfer/bandwidth. However, you also have dynamic images which get regularly updated, and you don't want them to be cached. So what do you do?

This is forehead slappingly simple, but always overlooked! The usual method is the Pragma No-Cache which isn't always that reliable any way. However, this will (usually) prevent everything from being cached, including the static images such as those in your web site design. That will mean slower page load times, and increased data transfer/bandwidth.

If you have programmed your site in PHP there is a very simple solution! Simply add "?rand=<?=rand(1,1000);?>" to the end of dynamic image URLs. For example "/graph.jpg?rand=<?=rand(1,1000);?>". In other words, the images that are updated regularly, such as web cam, wind direction, etc. What this does is add a random number to the end of the image file name, and so the file name changes every time the page is reloaded! So your permanent graphics, such as design elements of your page, photos etc will be cached, but the dynamic images will never be cached!

Subscribe to our Weather Tech Email!

Not only can I keep you up to date with my own new scripts, script updates, and top tips, but I'm hoping to get other weather script and software developers to share their news and updates too. Use the form on the right to subscribe!

If you develop weather web scripts or software, we would like to feature your news in the Weather Tech email too! Please contact me for details.

Weather Tech Email
Stay up to date!
Email
First Name
Location




Save The River Yealm


N&N Email Service
W/E forecast & tides ..?
Daily forecast & tides ..?
Site Updates ..?
Your Email
Your First Name

You can cancel your subscription at any time.
SAVE THE YEALM
Please click here to learn why The River Yealm is in danger, and to find out what you can do to help.... more

Under Construction!
This is part of a larger site that is currently in development. More info will be available soon.

 
   
Page loaded in 0.0044 secs.


© NewtonAndNoss.com 2001 - 2009