Enable and leverage browser caching for your website using the .htaccess file. Useful to improve performance or if the customer is reporting that website is slow.
Related Articles
Install and Configure W3 Total Cache
Disable Caching on Website
Enable Browser Caching
- Log into the cPanel
- Navigate to the File Manager, located in the Files section
- Navigate to the document root of the website
- Edit the .htaccess file
TIP: If .htaccess is not present, show hidden files in File Manager. - Add the code below to the .htaccess file and modify it as needed
NOTE: Be careful when enabling browser caching. If parameters are set too long on certain files, visitors might not be getting an updated version of the website after updates are made.
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Others
ExpiresByType application/pdf "access plus 1 month"
</IfModule> - Save the file