Knowledge Base
MilesWeb / How-Tos

How to configure mod_expires headers to manage cache?

Approx. read time : 2 min

 What is mod_expires?

Mod_expires is an Apache module that instructs web browsers on how to manage the cache. The mod_expires values inform web browsers about how long to store images, HTML files, and so on. Such configurations will result in quicker page load times for subsequent requests from the same user.

The mod_expires module manages 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 be specified to be relative to either the last time the source file was last modified or the time the client accessed the file.

Apache mod_expires page

Use the following code to verify if the expires module is loaded:

 Configuring mod_expires rules

You can configure mod_expires rules in the .htaccess file from the root directory of your site.


You can add or remove MIME types as per your needs. You can use the above as a template.

The objective is to specify which MIME types should be cached. Begin each line with ExpiresByType, then MIME type followed by time period.

Testing if mod_expires works

Use the curl command to access a file from the site if you have SSH access.

For accessing a png file, here is an example:

The above example explains that the server is instructing the client to cache the file for one year i.e. from the present date till 9 November 2022.

Related Article: Learn to configure caching with the mod_expires module

That is how you can manage the cache on your web browser using Apache module mod_expires.

Prajakta Marathe
Prajakta is a content writer at MilesWeb. She is ardent about writing technical and non-technical blogs. Adding value to know-how is what she believes in. She also has good experience in educational field. Gratified in sharing knowledge.