Enable browser caching to reduce website loading times, reduce server load, and reduce bandwidth usage. Browser caching functions by caching specific file types in the web browser.
What is Browser Caching?
Browser caching functions by caching specific file types in the web browser, which will be loaded automatically from cache and not from server.
Benefits of browser caching include:
reduced load times for websites
reduce server load
reduce bandwidth usage
Enable Browser Caching for all cPanel users in WHM
For server administrators of cPanel VPS hosting or dedicated servers (with root level access), this can be achieved on a server-wide basis by using the Apache Includes Editor in WHM (Web Host Manager).
From WHM admin, as root user, navigate to Server Configuration -> Apache Configuration -> Includes Editor. Find the "Post Virtual Include" entry and select "All Versions" from the dropdown menu.
Add the following lines of text:
Click "save" to write the changes to your server configuration.
To enable browser caching of a specific website, simply add the following line to the .htaccess file of the document root:
RewriteRule ^(css|js)/(.*)\.[0-9]+\.(.*)$ /$1/$2.$3 [L]
To automatically enable browser caching for all users and websites, add an .htaccess file with the above line of text to the cPanel Skeleton directory.
The specified file types will now be cached in web browsers to prevent loading on every access. This will speed up the website loading time. Browser caching also helps reducing the server load and bandwidth usage.
For alternative methods of enabling browser caching, see Enable Browser Caching with .htaccess File (enables browser caching on a per-site basis for shared hosting and reseller hosting administrators).