Trellis+ bedrock + sage | ‘Leverage browser caching’ Google PageSpeed Fix

Hi everyone, who ever managed to solve the problem with ‘Leverage browser caching’ Google PageSpeed ​​???

I re-done everything that is written here, in addition to this many other options, but page speed vseravno says that the files are not cached …

At the moment I have trellis/nginx-includes/example.com/cache.conf.j2 with the contents

# PDF
  location ~*  \.(pdf)$ {
  expires 1d;
  add_header Cache-Control "public, max-age=86400";
}

# Feed
location ~* \.(?:rss|atom)$ {
  expires 1d;
  add_header Cache-Control "public, max-age=86400";
}

# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc)$ {
  expires 30d;
  access_log off;
  gzip_vary on;
  add_header Cache-Control "public, max-age=2629000";
}

# Media: svgz files are already compressed.
location ~* \.svgz$ {
  expires 30d;
  access_log off;
  gzip off;
  add_header Cache-Control "public, max-age=2629000";
}

# CSS and Javascript
location ~* \.(?:css|js)$ {
  expires 1y;
  access_log off;
  add_header Cache-Control "public, max-age=31536000";
}

# WebFonts
# If you are NOT using cross-domain-fonts.conf, uncomment the following directive
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
  expires 1y;
  access_log off;
  add_header Cache-Control "public, max-age=31536000";
}

and the command ansible-playbook server.yml -e env=production --tags nginx-includes

But there is no effect (…

tried the solutions of these topics:


Does anyone have any ideas how to fix this ???

I don’t think nginx-includes is a tag. You should try nginx,wordpress-setup.

@ben

Thanks for your reply.

I tried these tags, it does not help either.

The solution came across here:

everything worked after sudo systemctl restart nginx


1504

2 Likes