I am trying to create a htaccess file for my website and the pageSpeed insights has shown that there are images and one css file without expiration.
I am not sure where to start with this or how to do it, I have this code from a tutorial online and was wondering if this would be enough to work.
<IfModule mod_expires.c> ExpiresActive On ############################################ ## Add default Expires header ## http://developer.yahoo.com/performance/rules.html#expires <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> ExpiresDefault "access plus 1 year" </FilesMatch> </IfModule>
Or does this code do what I need it to do?
Thanks
To leverage your browser's caching generally means that you can specify how long web browsers should keep images, CSS and JS stored locally. That way the user's browser will download less data while navigating through your pages, which will improve the loading speed of your website.
To fix the leverage browser caching warning with WP Rocket, all you have to do is install and activate the plugin. That's it. For more details, see our guide on how to properly install and setup WP Rocket in WordPress. WP Rocket will automatically enable browser caching and modify your .
Fixing Leverage Browser Caching in WordPress with the W3 Total Cache can be done by following the steps listed below: Download and install the W3 Total Cache WordPress plugin. Navigate to General Settings and select Enable Browser Cache. Click save and navigate to Browser Cache Settings (top of the page)
try something like
<IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 1 seconds" ExpiresByType text/html "access plus 1 seconds" ExpiresByType image/x-icon "access plus 2592000 seconds" ExpiresByType image/gif "access plus 2592000 seconds" ExpiresByType image/jpeg "access plus 2592000 seconds" ExpiresByType image/png "access plus 2592000 seconds" ExpiresByType text/css "access plus 604800 seconds" ExpiresByType text/javascript "access plus 86400 seconds" ExpiresByType application/x-javascript "access plus 86400 seconds" </IfModule>
or
<FilesMatch "\.(?i:gif|jpe?g|png|ico|css|js|swf)$"> <IfModule mod_headers.c> Header set Cache-Control "max-age=172800, public, must-revalidate" </IfModule> </FilesMatch>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With