mod_expires or mod_headers?
Asked Answered
P

1

6

This page says this:

If a response includes both an Expires header and a max-age directive, the max-age directive overrides the Expires header, even if the Expires header is more restrictive

It seems like both of the mod_expires and mod_headers are active in my server.
Which of them is preferable and can you comment the advantages of each of them?
Thank you.

Propagate answered 28/8, 2012 at 17:45 Comment(4)
What are you planning to use them for?Daguerreotype
I will use them for leveraging browser cache for my css, js etc. filesPropagate
Are you expecting to tell the browser that you want the file to remain in cache for X amount of time, or are you more interested in telling them to keep the file until some specific date (i.e. maybe dates around which you typically do production deployments)Daguerreotype
I want to tell browser that, don't re-download these files until the time after 2 days of access time.Propagate
D
8

You probably just want to use mod_expires, as this allow for sending of both Cache-Control header and Expires headers automatically and can allow you to specify by both access time and file modification time. It also allows you to set different defaults by file type.

Using mod_expires you could set the default expiry using the following directive:

ExpiresDefault "access plus 2 days"

Of course mod_headers is a much more general module that allows you to do some of the same stuff, but generally used more for creating custom headers or manage multiple (possibly conflicting) headers.

Daguerreotype answered 28/8, 2012 at 18:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.