O
O
Optimus2017-09-26 18:30:47
Search Engine Optimization
Optimus, 2017-09-26 18:30:47

How to cache for Google Page Speed?

Googled, they write to add entries like this to htaccess:

<IfModule mod_expires.c>
# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf|css)$">
Header set Cache-Control "max-age=694800, public"
</FilesMatch>
</IfModule>

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 8 days"
</IfModule>

I tried both the first option and the second, anyway, google says that there is no cache.
Somehow it is possible to give the necessary data using PHP, I only know the title of the form:
header('Last-Modified: Mon, 18 Oct 2017 14:15:00 GMT');

Is it enough or do you need to send some other headers in addition to it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Exploding, 2017-09-26
@Exploding

Something like this ... Well, you can already set up the types and terms there yourself.

<FilesMatch "\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|js|css)$">
  ExpiresActive on
   ExpiresDefault "access plus 35 days"
</FilesMatch>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question