It’s pretty image heavy and google page speed is complaining -
Leverage browser caching
Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
I see people using this in their nginx server configs:
Added that to my site’s config block, restarted nginx and seemed to remove the Pagespeed warning although it didn’t improve my score much (from 94 -> 95).
You’d want to use Trellis’ Nginx includes feature to add a config like @cfx showed.
Keep in mind that by setting a 30d cache (for example) on images, clients may not see updated images (if you changed an existing image) for up to 30 days unless you had an automated system to append some version/hash to the filename.
I’m trying to achieve the same thing as @davidmichelruddy and improve my GT Metrix score by adding expiration date to static resources to my Nginx configuration in my Trellis 0.9.9 project.
So I tried the Nginx includes route and added a folder nginx-includes in my trellis root with a subfolder for each site key:
I reprovisioned my remote server with the nginx-includes tag like this without any errors: ansible-playbook server.yml -e env=production --tags nginx-includes
Supposedly this folder should have been created /etc/nginx/includes.d/ but that didn’t happen. A full reprovision didn’t create that folder either.
The Nginx includes documentation states the following:
Deprecated templates directory
The original implementation of Trellis Nginx includes required template files to be stored in roles/wordpress-setup/templates/includes.d. That directory is now deprecated and will no longer function beginning with Trellis 1.0. Please move your templates to a directory named nginx-includes in the root of this project. It is preferable to store user-created templates separate from Trellis core files.
But since there’s isn’t a Trellis version 1.0 tagged yet, I assume we should still create the file like this?
When I place my file there and reprovision the remote server, the folder /etc/nginx/includes.d/ is also not created and there is no effect in the Leverage browser caching score.
Yes, the site key/name from wordpress_sites has to match the folder names under nginx-includes.
For anyone else in this thread, please use the newer nginx-includes folder.
We will remove the the one under roles/wordpress-setup at some point and your template won’t be copied over
@Twansparant I’m not really sure what’s going on for you. Have you been updating Trellis manually? My only guess so far is that something might have been missed in that process.
Assuming your folders are correct with the proper names.