Solved

Expiration of cached adaptive images

Posted on 2013-05-28
5
298 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 camera licenses with purchase of My Cloud NAS

Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Form Processing in PHP 11 32
PHP warning 4 30
updating the date data 12 23
Crazy text will not be removed no matter what I try! 13 15
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logiā€¦
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

15 Experts available now in Live!

Get 1:1 Help Now