LBC reduces server load and load times by marking and storing certain pages, or parts of pages in the browser. Then it marks the files as being needed to be updated at various internals.
ToolKit For Elementor allows users to 1-click activate Leverage Browser Caching for Apache servers.
When you enable LBC on an Apache server, ToolKit automatically adds this code to your site’s .htaccess file:
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault “access plus 1 week”
# CSS
ExpiresByType text/css “access plus 1 week”
# Data interchange
ExpiresByType application/atom+xml “access plus 1 hour”
ExpiresByType application/rdf+xml “access plus 1 hour”
ExpiresByType application/rss+xml “access plus 1 hour”
ExpiresByType application/json “access plus 0 seconds”
ExpiresByType application/ld+json “access plus 0 seconds”
ExpiresByType application/schema+json “access plus 0 seconds”
ExpiresByType application/vnd.geo+json “access plus 0 seconds”
ExpiresByType application/xml “access plus 0 seconds”
ExpiresByType text/calendar “access plus 0 seconds”
ExpiresByType text/xml “access plus 0 seconds”
# Favicon (cannot be renamed!) and cursor images
ExpiresByType image/vnd.microsoft.icon “access plus 1 year”
ExpiresByType image/x-icon “access plus 1 year”
# HTML
ExpiresByType text/html “access plus 0 seconds”
# JavaScript
ExpiresByType application/javascript “access plus 1 week”
ExpiresByType application/x-javascript “access plus 1 week”
ExpiresByType application/js “access plus 1 week”
ExpiresByType text/javascript “access plus 1 week”
# Manifest files
ExpiresByType application/manifest+json “access plus 1 week”
ExpiresByType application/x-web-app-manifest+json “access plus 0 seconds”
ExpiresByType text/cache-manifest “access plus 0 seconds”
# Markdown
ExpiresByType text/markdown “access plus 0 seconds”
# Media files
ExpiresByType audio/ogg “access plus 1 week”
ExpiresByType image/bmp “access plus 1 week”
ExpiresByType image/gif “access plus 1 week”
ExpiresByType image/jpeg “access plus 1 week”
ExpiresByType image/jpg “access plus 1 week”
ExpiresByType image/png “access plus 1 week”
ExpiresByType image/svg+xml “access plus 1 week”
ExpiresByType image/webp “access plus 1 week”
ExpiresByType video/mp4 “access plus 1 week”
ExpiresByType video/ogg “access plus 1 week”
ExpiresByType video/webm “access plus 1 week”
# WebAssembly
ExpiresByType application/wasm “access plus 1 month”
# Web fonts
ExpiresByType font/collection “access plus 1 month”
# Embedded OpenType (EOT)
ExpiresByType application/vnd.ms-fontobject “access plus 1 month”
ExpiresByType font/eot “access plus 1 month”
# OpenType
ExpiresByType font/opentype “access plus 1 month”
ExpiresByType font/otf “access plus 1 month”
# TrueType
ExpiresByType application/x-font-ttf “access plus 1 month” ExpiresByType font/ttf “access plus 1 month”
# Web Open Font Format (WOFF) 1.0
ExpiresByType application/font-woff “access plus 1 month”
ExpiresByType application/x-font-woff “access plus 1 month”
ExpiresByType font/woff “access plus 1 month”
# Web Open Font Format (WOFF) 2.0
ExpiresByType application/font-woff2 “access plus 1 month”
ExpiresByType font/woff2 “access plus 1 month”
# Other
ExpiresByType text/x-cross-domain-policy “access plus 1 week”
</IfModule>
On NGINX servers, performance plugins are not able to automatically make server-level tweaks. and so you’ll need to manually add this to your server block. Learn More Here.
location ~* .(js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|woff|woff2|svg)$ {
expires 30d;
add_header Pragma “public”;
add_header Cache-Control “public”;
}
Then, restart your server using the following:
$ service nginx restart
For LiteSpeed servers, check out their guide to Leverage Browser Caching here.
Want to learn more about Leverage Browser Caching?
Check out this awesome explanation on LBC and how it works
How to enable Leverage Browser Caching on NGINX (From Plesk)