Solved

Expiration of cached adaptive images

Posted on 2013-05-28
5
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The goal of this is to tech the user how to export photos out of Lightroom and the different options they have. Select which photos you want to export : Select where you want to export and with which options : Export :
The goal of the tutorial is to teach the user how to edit a basic portrait of someone. This tutorial shows how to edit two basic photographs, one of a car and one of a person.

739 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