Solved

Expiration of cached adaptive images

Posted on 2013-05-28
5
296 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The goal of the tutorial is to teach the user how to import photos into Adobe Lightroom efficiently and to keep everything organized.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now