Select Page

Speed up your apache server with mod_expires

This module controls 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 set to be relative to either the time the source file was last modified, or to the time of the client access.

These HTTP headers are an instruction to the client about the document’s validity and persistence. If cached, the document may be fetched from the cache rather than from the source until this time has passed. After that, the cache copy is considered "expired" and invalid, and a new copy must be obtained from the source.

How to activate mod_expires.so
# vi /etc/apache2/conf.d/mod_expires.conf

config is rough right now, but it is better than nothing,put the following in the file

LoadModule evasive20_module     /usr/lib/apache2/mod_expires.so
<IfModule mod_expires.c>
 ExpiresActive On

 ExpiresDefault "access plus 1 month"
 #ExpiresByType text/html "access plus 1 month 15 days 2 hours"
 #ExpiresByType image/gif "modification plus 1 month"
 #ExpiresByType image/png "modification plus 1 month"
 #ExpiresByType image/jpg "modification plus 1 month"
 #ExpiresByType text/css "access plus 1 month 15 days 2 hours"
 #ExpiresByType text/javascript "access plus 1 month 15 days 2 hours"
</IfModule>

You can also set the expire header by type, but it wa snot working in my case, that is why I use the ExpiresDefault directive

About The Author

I worked with various Insurances companies across Switzerland on online applications handling billion premium volumes. I love to continuously spark my creativity in many different and challenging open-source projects fueled by my great passion for innovation and blockchain technology.In my technical role as a senior software engineer and Blockchain consultant, I help to define and implement innovative solutions in the scope of both blockchain and traditional products, solutions, and services. I can support the full spectrum of software development activities, starting from analyzing ideas and business cases and up to the production deployment of the solutions.I'm the Founder and CEO of Disruptr GmbH.

Categories