Example: Caching management

In order for the site to work as efficiently as possible, it is advisable to set the caching time for various types of files for as long as possible. There is an Apache mod expires module for this.

The parameters of the mod_expires module are configured in a file .htaccess, which allows you to make individual settings for each directory.

In the example below, caching is disabled for text documents, the update period is set for files with the gif extension — 3 months from the date of file change, for files with the jpeg extension — 1 day from the date of access:

ExpiresActive on
ExpiresByType image/jpeg "access plus 1 day"
ExpiresByType image/gif "modification plus 3 months"
ExpiresByType text/html "now"