How to Check if mod_expires is enabled

check if mod_expires enabled

Apache allows you to setup content caching in many different ways, thereby reducing server load and improving website speed. However, to setup content caching in Apache, it is necessary to ensure that the required modules have been enabled properly. mod_expires is one such module which needs to be enabled for content caching. If it is not enabled, then caching will not work properly. Let us look at how to check if mod_expires is enabled.


What is mod_expires?

Setting expiration periods for content allows web browsers to cache them for a specific period of time. This reduces the number of requests sent by the web browsers to your web server. mod_expires module enables you to set expiration periods for each type of content on your website. For example, mod_expires allows you to instruct web browsers to cache images for 1 week, Javascript files for 1 day and CSS files for 1 month. Here’s the code for it. You can add it to your Apache config file or .htaccess file to

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/png "access 1 hour"
  ExpiresByType image/gif "access 1 hour"
  ExpiresByType image/jpeg "access 1 hour"
  ExpiresByType text/javascript "access 2 weeks"
  ExpiresByType text/css "access 2 months"
  ExpiresByType text/html "modification 4 hours"
  ExpiresDefault "access 2 days"

In the above example, ExpiresActive turns on mod_expires. ExpiresByType sets the expiration period for the specified content type.


How to Check if mod_expires is enabled

You can easily check if mod_expires is enabled with the following command, depending on your OS. On running the following command, Apache will show you all the enabled modules. Please note, Apache doesn’t allow you to specifically look for a single module.

On Debian:

$ /usr/sbin/apache2 -l

Most GNU/Linux distros:

$ /usr/sbin/httpd -l

On Mac OSX:

$ httpd -l

On Win 7 (64-bit):

C:\Users\myuser>"\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe" -l

Try these commands from a terminal window (CMD in case of Windows).


That’s it! Each of the above commands will list all the enabled modules. If mod_expires is enabled in your Apache server, you should find it in the output list.

About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!