How to enable mod_expires with your Virtual Machine?


This mod_expires is a apache web server module which 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.


The HTTP headers are nothing but a small 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. Once time is passed, the cache copy is considered "expired" and invalid, and a new copy must be obtained from the source.


If you are not having any access to apache configuration files, then don't worry it is also possible to add those lines given below under .htaccess files which will be present under your code deployed path i.e


/var/sentora/hostdata/username/public_html


<IfModule mod_expires.c>

# Enable expirations

ExpiresActive On

# Default directive

ExpiresDefault "access plus 1 month"

# My favicon

ExpiresByType image/x-icon "access plus 1 year"

# Images

ExpiresByType image/gif "access plus 1 month"

ExpiresByType image/png "access plus 1 month"

ExpiresByType image/jpg "access plus 1 month"

ExpiresByType image/jpeg "access plus 1 month"

# CSS

ExpiresByType text/css "access plus 1 month"

# Javascript

ExpiresByType application/javascript "access plus 1 year"

</IfModule>


Once these lines are added under your .htaccess file then save it.


Now it reduce HTTP requests which reduces the time to take for the server to communicate with the browser. It also allows your users to reuse the cache files that have been stored in the browser to reduce the amount of files they need to download.


How to check whether this mod_expires is enabled or not:


  • Type <?php phpinfo(); ?> in a php file and save it and run that file in the server.


  • Now you can the list of informations, just search the word “mod_rewrite” from the browser’s search menu.


  • Under the “Loaded Modules” section this module is already loaded as you see in the picture below:




If you are looking to buy VPS Hosting servers for your website then you are at the right place. Here at HostingRaja, we provide Fully managed, performance-tuned Secure VPS Servers. Not only that we also provide amazing features, offers and discounts upto 55% for our VPS hosting serves. So what are you waiting for buy your VPS hosting services from India's No1 VPS hosting provider.