To enable browser caching in cPanel, you'll need to edit the .htaccess file located in your website’s root directory.
-
Log in to your cPanel account.
-
Open File Manager and navigate to the folder where your website is installed (usually public_html).
-
Locate and open the .htaccess file. If it’s not visible, enable “Show Hidden Files” in File Manager settings.
-
Add caching rules by inserting code that defines expiration times for file types like images, CSS, and JavaScript.
Here’s a basic example of what to add:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
</IfModule>
This tells the browser to store frequently used files locally, which speeds up page load times and reduces server load.