Question

How to enable mod_expires in Digital Ocean?

I have been asked to enable mod_expires in digital ocean for header caching as well as browser caching. I don’t know where to look and enable it. If someone kind enough to share me document link or any guidance would be appreciated.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
February 12, 2023

Hey @243261243130244e585741572f7544,

First you should check if it’s already enabled. To do so, you can run the following on CentOS

  1. httpd -M | grep expires

If nothing appears as output then you don’t have it enabled. Another way to verify it is via httpd.conf file, open apache configuration file in your favorite text editor application (Vi/ViM, Nano etc) and search for following line. If successfully found, then your Apache has mod_expires enabled.

LoadModule expires_module modules/mod_expires.so

For Ubuntu system, we need to use a2enmod utility to enable Apache modules, simply run following command to enable expires module on Ubuntu.

a2enmod expires

Once done, we need to restart apache for this change to take effect.

/etc/init.d/apache2 restart

Now you have it enabled however you’ll need to configure it for extensions you need to cache. Now that’s entierly up to your preferences but there are different settings for that. You can check how to configure .jpeg or similar extenions.

Hope that helps.

alexdo
Site Moderator
Site Moderator badge
September 1, 2022

Hello @kunalchauhan

mod_expires should come with the default Apache installation, but you can check if the module is both installed and loaded using these commands

  1. apachectl -M | grep expires

If mod_expires is not enabled or installed you can run the following command to install mod_expires on Ubuntu/Debian systems

  1. sudo a2enmod mod_expires

Then you need to restart Apache

  1. service apache2 restart

That’s it, you now have mod_expires enabled.

Hope that this helps!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel