D
D
Denis Shishkin2016-03-17 06:33:41
htaccess
Denis Shishkin, 2016-03-17 06:33:41

How to use browser cache (Wordpress)?

I check the site on Google pagespeed, and there is one obligatory advice left: Use the browser cache. I added the following code to the htacces file

FileETag MTime Size
<ifmodule mod_expires.c>
<filesmatch "\.(jpg|gif|png|css|js)$">
ExpiresActive on
ExpiresDefault "access plus 1 year"
</filesmatch>
</ifmodule>

But Google pagespeed still shows this remark .. Tell me, maybe you need to configure it somehow differently? And caching plugins are worth WP Super Cache
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Soslan Aldatov, 2016-03-17
@sptm

Everything is correct, but you need to see which files are not cached and add their extensions to filesmatch.
I do not remember if Pagespeed shows a list of such files, but the same GTMetrix will definitely show them.
Edit: and add mod_headers, something like this:

<ifModule mod_headers.c>
    <FilesMatch "\.(html|htm)$">
        Header set Cache-Control "max-age=43200"
    </FilesMatch>
    <FilesMatch "\.(js|css|txt)$">
        Header set Cache-Control "max-age=604800"
    </FilesMatch>
    <FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$">
        Header set Cache-Control "max-age=2592000"
    </FilesMatch>
    <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
        Header unset Cache-Control
    </FilesMatch>
</IfModule>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question