Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_expires or mod_headers?

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.

like image 210
trante Avatar asked Aug 28 '12 17:08

trante


People also ask

What is Mod_expires?

Module: mod_expires. This directive defines the value of the Expires header and the max-age directive of the Cache-Control header generated for documents of the specified type (e.g., text/html ). The second argument sets the number of seconds that will be added to a base time to construct the expiration date.

How do you check if Mod_expires is enabled?

You can simply use apachectl -M command to list all the enabled modules in Apache web server. Since the output contains a list of all installed modules in Apache, we can pass its output to grep and search for “expires” string. If the output contains “expires_module” it means mod_expires is enabled.

What is Ifmodule Mod_expires C?

Mod_expires is an Apache module that is used to manipulate the Expires HTTP header and the max-age directive of the Cache-Control header. These two HTTP headers instruct the internet browser of the client for how long should particular documents and files be cached.


1 Answers

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.

like image 162
Mike Brant Avatar answered Sep 19 '22 12:09

Mike Brant