• Services
    • Web Hosting
    • Reseller Hosting
    • VPS Hosting
    • Dedicated Hosting
  • Domains
  • Features
  • Company
    • About Us
    • Server Locations
    • Affiliates
    • Company Blog
  • Support
  • Client Login
  • Services
    • Web Hosting
    • Reseller Hosting
    • VPS Hosting
    • Dedicated Hosting
  • Domains
  • Features
  • Company
    • About Us
    • Server Locations
    • Affiliates
    • Company Blog
  • Support
  • Client Login
Home/Article/Websites/Website Optimization/How to Enable Leverage Browser Caching on Website?

How to Enable Leverage Browser Caching on Website?

Written by VernalWeb
November 20, 2023

Leverage Browser Caching is a crucial aspect of optimizing your website’s performance. It involves instructing web browsers to store certain files locally, reducing load times for returning visitors. In this article, we’ll delve into the basics of Leverage Browser Caching, its benefits, and how to enable it for your website.

What is Leverage Browser Caching?

Leverage Browser Caching is a technique that allows webmasters to specify how long web browsers should cache static resources, such as images, CSS files, and JavaScript, on a user’s device. When a user visits a website, their browser can store these resources locally, enabling faster page loading times for subsequent visits.

Benefits of LBC

  1. Improved Page Load Speed: By caching static resources, returning visitors experience faster load times, enhancing overall user experience.
  2. Reduced Server Load: Caching resources locally reduces the number of requests made to the server, lightening the server load and improving overall website performance.
  3. Bandwidth Savings: Users benefit from reduced bandwidth consumption as cached resources eliminate the need to download the same files repeatedly.

How to Enable Leverage Browser Caching

Enabling LBC involves modifying your website’s server configuration or adding code to your .htaccess file. Follow these steps:

  1. Access Your Server: Log in to your web server using FTP or a file manager.
  2. Locate the .htaccess File: The .htaccess file is a configuration file for Apache servers. Find it in your website’s root directory.
  3. Backup Your .htaccess File: Before making any changes, create a backup of your .htaccess file to avoid potential issues.
  4. Edit the .htaccess File: Add the following code:
  1. ## EXPIRES CACHING ##
    
    ExpiresActive on
    
    # Set Expires Default
    ExpiresDefault                          "access plus 1 year"
    
    # Set Expires Header for cache.
    ExpiresByType text/cache-manifest       "access plus 0 seconds"
    
    # Your document html
    ExpiresByType text/html                 "access plus 0 seconds"
    
    # Data
    ExpiresByType text/xml                  "access plus 0 seconds"
    ExpiresByType application/xml           "access plus 0 seconds"
    ExpiresByType application/json          "access plus 0 seconds"
    
    # RSS Feed
    ExpiresByType application/rss+xml       "access plus 1 hour"
    ExpiresByType application/atom+xml      "access plus 1 hour"
    
    # Favicon
    ExpiresByType image/x-icon              "access plus 1 week"
    
    # Media files - images, audio, video
    ExpiresByType image/gif                 "access plus 1 year"
    ExpiresByType image/png                 "access plus 1 year"
    ExpiresByType image/jpeg                "access plus 1 year"
    ExpiresByType video/ogg                 "access plus 1 year"
    ExpiresByType audio/ogg                 "access plus 1 year"
    ExpiresByType audio/mp3                 "access plus 1 year"
    ExpiresByType video/mp4                 "access plus 1 year"
    ExpiresByType video/webm                "access plus 1 yar"
    
    # HTC files
    ExpiresByType text/x-component          "access plus 1 year"
    
    # Various Webfonts
    ExpiresByType application/x-font-ttf    "access plus 1 month"
    ExpiresByType font/opentype             "access plus 1 month"
    ExpiresByType application/x-font-woff   "access plus 1 month"
    ExpiresByType application/x-font-woff2  "access plus 1 month"
    ExpiresByType image/svg+xml             "access plus 1 month"
    ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
    
    # CSS and JavaScript
    ExpiresByType text/css                  "access plus 1 year"
    ExpiresByType application/javascript    "access plus 1 year"
    ## EXPIRES CACHING ##
    
  2. Save and Upload: Save the changes to your .htaccess file and upload it back to your server.
  3. Check Your Website: Verify that LBC is working by testing your website’s performance using online tools like Google PageSpeed Insights.

Conclusion

By following these simple steps to activate LBC, you can enhance user experience, reduce server load, and improve overall website efficiency. Keep in mind that regular monitoring and adjustments may be necessary to ensure continued optimal performance.

Tags:htaccessLeverage Browser CachingWebsite Optimization

Was this helpful?

Yes  No
Related Articles
  • How to Activate Cloudflare on a Subdomain
  • What is Keep-Alive and How to Enable it on Website?

Didn't find your answer? Submit Ticket

Latest Articles

  • How to show Hidden Files (.htaccess) in cPanel File Manager
  • Setup a Domain Redirection in cPanel
  • Create a MySQL Database and a User from cPanel
  • Remove page extensions using .htaccess
  • Cron Job Usage & Policy
  • © 2014 - 2025 VernalWeb. All rights reserved.