Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Expiration of cached adaptive images

Posted on 2013-05-28
5
Medium Priority
?
344 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 500 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 43

Accepted Solution

by:
David S. earned 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The goal of the tutorial is to teach the user how to import photos into Adobe Lightroom efficiently and to keep everything organized.
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.
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

885 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