What is mod_expires caching ?
Mod_expires caching is a powerful tool that can be used to improve the performance of your website. By caching static files, mod_expires can reduce the number of requests that need to be made to the server, which can lead to significant performance improvements.
When a user visits your website, their browser will first check to see if it has a cached copy of the static content. If the browser has a cached copy of the content, it will display the cached copy instead of downloading the content from the server. This can save a lot of time and bandwidth, especially for users who are visiting your website for the first time.
To use mod_expires caching, you need to:
- Enable the mod_expires module in Apache. You can do this by adding the following line to your Apache configuration file:
/opt/lampp/etc/httpd.conf
open “httpd.conf” file and add below code
LoadModule expires_module modules/mod_expires.so
Next go to below path and open httpd-vhosts.conf file
opt/lampp/etc/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin contact@wizbrand.com
DocumentRoot "/opt/lampp/htdocs/wizbrand/wz-account-admin-ms/public"
ServerName wizbrand.com
LoadModule expires_module modules/mod_expires.so
ExpiresByType image/png "access plus 1 hour"
ExpiresByType image/gif "access plus 1 hour"
ExpiresByType image/jpeg "access plus 1 hour"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/html "access plus 1 day"
Redirect permanent / https://www.wizbrand.com/
Alias /site-admin /opt/lampp/htdocs/wizbrand/wz-siteadmin-ms/public
<Directory "/opt/lampp/htdocs/wizbrand/wz-siteadmin-ms/public">
Options Indexes FollowSymLinks
AllowOverride All
Allow from all
Require all granted
</Directory>
</VirtualHost>
Next restart the apache server
sudo /opt/lampp/lampp restart
These directives will tell Apache to cache PNG, GIF, JPEG, JavaScript, CSS, and HTML files for the specified amount of time. By reducing the number of requests that need to be made to the server, mod_expires can help to improve the scalability of web applications. This means that web applications can handle more concurrent users without experiencing performance problems.
Thanks for learning 👍👍
[…] Using of mod_expires caching for improve Performance ? […]