Last updated on August 10th, 2020 at 03:05 am
mod_expires is an Apache module that allows you to set the expiration time for different types of content on your website, to cache content. Many times you may need to check if mod_expires is enabled in Apache web server. Here’s how to check if mod_expires is enabled or not.
How to Check if mod_expires is enabled
Here are the steps to check if mod_expires is enabled in Apache web server.
1. 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. If the output is blank, then it means mod_expires is not enabled.
Here’s an example
~$ apachectl -M | grep expires expires_module (shared)
Bonus Read : How to Enable mod_headers in Apache
2. Install mod_expires
If mod_expires is not enabled or installed you can run the following command to install mod_expires on Ubuntu/Debian systems
$ sudo a2enmod mod_expires
In case of CentOS/Redhat/Fedora systems, you need to edit httpd.conf configuration file and uncomment the following line
#LoadModule expires_module modules/mod_expires.so
by removing # in front of it.
LoadModule expires_module modules/mod_expires.so
If # is not present before the above line, it means mod_expires is already enabled in your Apache web server
Bonus Read : How to Secure Apache with Let’s Encrypt
3. Restart Apache Server
Restart Apache web server to apply changes.
Ubuntu/Debian
$ sudo service apache2 restart
CentOS/Redhat/Fedora
$ systemctl restart httpd
Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!
Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI & software development.