Frequently Asked Questions • Dev
The analysis sites GTmetrix and PageSpeed recommend that I set up leverage-browser-caching. How can I do this?
Improve your website speed by setting leverage browser caching in the .htaccess file for Apache servers, using expiration rules for images, video, and static files.
Views 404Updated 6 aniPublished on 09/02/2019by Sebastian Szlivka
Leveraging browser caching consists of adding caching/expiration rules at the web server level that the browser accessing the website will take into account. Essentially, once downloaded, the cached elements will not be redownloaded until the expiration time set for caching has elapsed or a full refresh is performed on that page. Some caching rules that can be added to the .htaccess file in the case of an Apache web server are:
ExpiresActive On
# ImagesExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/webp "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType image/x-icon "access plus 1 year"
# Video ExpiresByType video/mp4 "access plus 1 year"ExpiresByType video/mpeg "access plus 1 year"
# CSS, JavaScript ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType application/javascript "access plus 1 month"
# Others ExpiresByType application/pdf "access plus 1 month" ExpiresByType application/x-shockwave-flash "access plus 1 month"