How to Enable Leverage Browser Caching, a cache medium operates between the garçon and the caller's cybersurfer, either on the end of the garçon or on the computer of the caller. It can store clones of lines ( like html, php, css, js lines, images,etc.) or strings of law for faster access rather than having to constantly request it from the boy. For websites, the most effective way to cache lines is to use cybersurfer hiding. But there are other ways to use caching to your advantage as well. Using one or multiple cache mechanisms for your website can greatly ameliorate the performance of your web servers.
Test Your URL
Check how well your web files are cached with the website speed test or the browser caching test.
What Do We Mean With Leverage Browser Caching?
The most important cache medium for runner speed is cybersurfer hiding. Most of the stationary lines that are used on web runners can be saved on the computer of your caller for unborn access. Every time the caller accesses a new runner on your website, these lines will also be penetrated from the caller's computer rather than yours, which will greatly speed up runner cargo times.
Leverage browser caching for Apache via the .htaccess file
You can work cybersurfer caching for Apache waiters by adding a small grain to the.htaccess train. Below are the two recommended ways of doing this:Mod_Expires (most commonly used option)
<IfModule mod_expires.c>ExpiresActive OnAddType application/vnd.ms-fontobject .eotAddType application/x-font-ttf .ttfAddType application/x-font-opentype .otfAddType application/x-font-woff .woffAddType image/svg+xml .svgExpiresByType application/vnd.ms-fontobject "access 1 year"ExpiresByType application/x-font-ttf "access 1 year"ExpiresByType application/x-font-opentype "access 1 year"ExpiresByType application/x-font-woff "access 1 year"ExpiresByType image/svg+xml "access 1 year"ExpiresByType text/html "access 1 hour"ExpiresByType text/css "access 14 days"ExpiresByType text/x-javascript "access 3 weeks"ExpiresByType application/javascript "access 1 month"ExpiresByType application/x-javascript "access 1 month"ExpiresByType image/gif "access 2 months"ExpiresByType image/png "access 2 months"ExpiresByType image/jpg "access 2 months"ExpiresByType image/jpeg "access 2 months"ExpiresByType image/gif "access 2 months"ExpiresByType application/pdf "access 1 year"ExpiresByType application/x-shockwave-flash "access 1 year"ExpiresByType image/x-icon "access 1 year"ExpiresDefault "access 2 days"</IfModule>
Not Working?
Make sure the mod_expires module is enabled on your server by running the following command via SSH access (or ask your host about this):
Add the following code to the .htaccess file. You can edit the filetypes and cache access times to your liking. Right now, the access time is set to 2592000 seconds, which is 30 days.
sudo a2enmod expiresMod_Headers (works just as well)
Add the following code to the .htaccess file. You can edit the filetypes and cache access times to your liking. Right now, the access time is set to 2592000 seconds, which is 30 days.
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">Header set Cache-Control "max-age=2592000, public"</FilesMatch>
Examples of various access times:
# 1 YEARHeader set Cache-Control "max-age=29030400, public"# 1 MONTHHeader set Cache-Control "max-age=2592000, public"# 1 WEEKHeader set Cache-Control "max-age=604800, public"# 1 HOURHeader set Cache-Control "max-age=3600, public"# DON'T CACHE ANY FILEHeader set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
Not Working?
Make sure the mod_headers module is enabled on your server by running the following command via SSH access (or ask your host about this):
sudo a2enmod headers