Hi folks,
just something easy, I think.
I have a Script, which retreives some Infos from 3rd party websites, and then generates an Image
out of the data.
Now, it can take some sec. before the Image is created and displayed on the screen.
What I would like to do is cache the Images for like one hour.
Everytime I use the script, it should check if there is a cache version available, check if this is still valid, and display it.
If it isn't vailid anymore, then he should do like always, grab info from Webpage, save it as cache and display it.
How would it be the easiest way to get this working ?
Thanks in advance.
Cache an Image
Moderators: onion2k, General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
use a hash of something unique from the request known ahead of time (if the sites vary) or the same filename if they don't and some time reference like filemtime()
Depending what you are doing and the complexity of the image, caching might be more trouble than it is worth. Your biggest overhead in this case is accessing 3rd party websites to collect data. Instead of caching the image itself you might want to consider caching the collected data and making the image on the fly on each access. Whether this is a good idea will depend on your specific case.