Solved

Expiration of cached adaptive images

Posted on 2013-05-28
5
307 Views
Last Modified: 2013-06-01
I'm trying out an adaptive image solution, wherein image requests are routed to a php file by htaccess.  The php file serves the visitor with a downsized version of the image, if the native image's width exceeds the visitor's screen width.  The downsized image is also cached.  My question pertains to some code in the php file, which removes the cached image after a configurable length of time.  So, is it desirable to keep cached images for a longer time, since other visitors with small screens might request the same image?
0
Comment
Question by:ddantes
5 Comments
 
LVL 18

Assisted Solution

by:Gary Davis
Gary Davis earned 125 total points
ID: 39212935
There is a trade-off of course. Caching longer than needed uses up resources and shorter than needed uses bandwidth.

A sliding expiration is desirable though I am not sure if PHP has it (DotNET does). This resets the cache expiration time every time the cached object is requested keeping oft-needed images in cache as long as they are needed and other fall out.

Another possibility is to use the "max-age" header to let the browser know the image should be cached there and not bother to check with the server to see if it has changed. This saves transaction hits to the server.

Gary Davis
0
 

Author Comment

by:ddantes
ID: 39213158
Thank you for your comment.  Would I include the max-age header in the <HEAD> section of my pages?

If the PHP file has a cache expiration of "365", does that keep images there in perpetuity, or do they still expire after a year?
0
 
LVL 42

Accepted Solution

by:
David S. earned 125 total points
ID: 39213621
I'd say it depends on how many images you're potentially dealing with and how much disk space is available on your server. Performance issues like this usually involve a trade-off.

I got the impression that this question is about server-side caching. Gary's point about "max-age" is a client-side caching feature, so it's not clear to me that it has much relevance to this question.

365 might well be in days, but I would not call that a safe assumption. When cached files actually would be removed after the specified time period depends on how it was programmed. The script might do it itself the next time it runs, or it might use a CRON-job that runs at a set interval to handle that.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The goal of the tutorial is to teach the user how to remove a natural vignette your photos and how to add vignette to your photos.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question