This module controls the setting of the Expires HTTP header and the max-age directive of the Cache-Control HTTP header in server responses. The expiration date can set to be relative to either the time the source file was last modified, or to the time of the client access.
These HTTP headers are an instruction to the client about the document's validity and persistence. If cached, the document may be fetched from the cache rather than from the source until this time has passed. After that, the cache copy is considered "expired" and invalid, and a new copy must be obtained from the source.
To modify Cache-Control directives other than max-age (see RFC 2616 section 14.9), you can use the Header directive.
When the Expires header is already part of the response generated by the server, for example when generated by a CGI script or proxied from an origin server, this module does not change or add an Expires or Cache-Control header.
The ExpiresDefault and ExpiresByType directives can also be defined in a more readable syntax of the form:
ExpiresDefault "base[plus num type] [num type] ..." ExpiresByType type/encoding "base[plus num type] [num type] ..."
where base is one of:
- now (equivalent to 'access')
The plus keyword is optional. num should be an integer value, and type is one of:
For example, any of the following directives can be used to make documents expire 1 month after being accessed, by default:
ExpiresDefault "access plus 1 month" ExpiresDefault "access plus 4 weeks" ExpiresDefault "access plus 30 days"
The expiry time can be fine-tuned by adding several 'num type' clauses:
ExpiresByType text/html "access plus 1 month 15 days 2 hours" ExpiresByType image/gif "modification plus 5 hours 3 minutes"
Note that if you use a modification date based setting, the Expires header will not be added to content that does not come from a file on disk. This is due to the fact that there is no modification time for such content.