Leveraging caching
Daisho Komiyama edited this page Jan 12, 2018
·
2 revisions
This time, I'm going to leverage browser caching.
Open server block file
sudo nano /etc/nginx/sites-available/mydomain.com
Then add these blocks
# Expires map
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/javascript max;
~image/ max;
}
expires $expires;
Your file would look like this
# Expires map
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/javascript max;
~image/ max;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
expires $expires;
. . .
Test
sudo nginx -t
Restart nginx
sudo systemctl restart nginx
Done. Check the result with GTmetrix and PageSpeed Insights