I'm using a minimal Ubuntu server 16.04 with Nginx 1.10.3 (to which I moved from Apache 2 days ago). On this environment, I run a minimal Wordpress site (5 plugins, no customization).
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
location ~* \.(pdf)$ {
expires 30d;
}
I pasted that code inside the server block in the default.conf
file of Nginx (to use it with other sites if I'd need), and restarted:
systemctl restart nginx.service
Yet when running GPI test I still get “Leverage browser caching” for many jpg files, even though “jpg” is already included in the directive.
All documentation I found, so far, deals exactly with what I already tried. Any ideas? Maybe most doc is outdated? Maybe that’s a bug in the current release of Nginx?
Мне пришлось поместить директиву об истечении срока действия кеша в блоке server
вместо блока http
.
Я вставил код в конец блока сервера site-conf, rstarted Nginx и тест GPI, никакой регистратор не показал уведомления.
location ~* \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff)$ {
expires 365d;
}
location ~* \.(pdf)$ {
expires 30d;
}
} # domain.tld.conf server block closure.