: How to set expire date for PageSpeed Insights google in Laravel? I create .htaccess in root project and add this code for set expire date for css and js. My server is Ubuntu 16.04 But this
I create .htaccess in root project and add this code for set expire date for css and js.
My server is Ubuntu 16.04
But this code not work for my website.
This code in htaccess:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch ".(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2692000, public"
</FilesMatch>
<FilesMatch ".(css)$">
Header set Cache-Control "max-age=2692000, public"
</FilesMatch>
<FilesMatch ".(js)$">
Header set Cache-Control "max-age=216000, private"
</FilesMatch>
<FilesMatch ".(x?html?|php)$">
Header set Cache-Control "max-age=600, private, must-revalidate"
</FilesMatch>
Header unset ETag
Header unset Last-Modified
</IfModule>
How do I fix the problem?
Thank you
More posts by @Kristi941
1 Comments
Sorted by latest first Latest Oldest Best
You need to ensure that mod_expires is actually enabled. On Ubuntu, it comes shipped with Apache2, but it is not enabled by default. To enable it, run the commands:
sudo a2enmod expires
sudo service apache2 reload
a2enmod is the apache2 script that enables a module. If you want to disable the module, you would use a2dismod instead.
After the module has been enabled, Apache2 much be either restarted, or it needs to reload its config files. The second command does the latter.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.