Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expires directive - modification base VS Access base

From what I know this:

ExpiresByType text/html "access plus 30 days"

will make the browser cache request for fresh content after storing the content die 30 days.

But with:

ExpiresByType text/html "modification plus 30 days"

the browser cache will know with the help of LAST MODIFIED HEADER not to request for fresh content until 30 days of modification.

So my question is, why not use Modification Base all the time as it seems to make better sense or is there something I am missing?

like image 804
Manish Pradhan Avatar asked Dec 21 '22 15:12

Manish Pradhan


1 Answers

The apache mod_expires docs say this:

The difference in effect is subtle. If M is used, all current copies of the document in all caches will expire at the same time, which can be good for something like a weekly notice that's always found at the same URL. If A is used, the date of expiration is different for each client; this can be good for image files that don't change very often, particularly for a set of related documents that all refer to the same images (i.e., the images will be accessed repeatedly within a relatively short timespan).

Where M is the modification plus and A is the access plus. So it looks like it's a matter of how you want to cache to work across all browsers. Do you want your resource to have its cache expire across all browsers all at the same time? Or do you want your resource to have its cache expiry staggered across all browsers? In particular, it comes down to the type of resource that's being cached here.

If I have a page for example, /live_shows.html that doesn't ever change except once a week, where I only ever update it at the beginning of the week to list all the live shows I'll have in my bar, then I'm going to want to use "modification plus 7 days". Because it's every 7 days that it'll be updated, no more, no less.

If I have a directory of images that are displayed on the /live_shows.html page, but rarely ever do they get changed because they're like icons and banners and bullets, I use them all the time. Then I'm going to want to make them "access plus 30 days" because it's not really that important to get updates for these changes, if there are ever any changes.

like image 200
Jon Lin Avatar answered Dec 28 '22 06:12

Jon Lin