I have a few questions about this directive:
If you have one place that is home to all your static files, something like this will do... location /static { your/location/to/static/files/static; expires 30d; add_header Cache-Control "public"; } The accepted answer caused nginx to not find any of my static files.
NGINX handles many thousands of simultaneous connections in a fixed memory footprint, so you don’t have to experience thrashing, nor limit simultaneous connections to a small number. NGINX also deals with static files better, with built‑in, easily tuned caching controls.
NGINX provides 2 special directive: X-Accel-Redirect <x-accel.redirect_> and map. Using these 2 directives, one can eliminate performance hit for static-file serving on WordPress multisite network. NGINX WordPress Shared Hosting Model - AnsiPress can be used.
Configuration options include database and object caching; minification for HTML, CSS, and JavaScript files; and integration options for popular CDNs. For NGINX configuration, see the Tips referenced in the list. Note: Caches do not work for users who are logged into WordPress, because their view of WordPress pages is personalized.
expires max;
sets browser cache expiration time in far future (2030 year). So, you should use it with caution. You will not be able to say to client, that file was changed. But, you would be able to rename file or to add some query to file name (e.g. "/style/main.css?v=2").
Always exclude location "favicon.ico" from expires max
. This location is hardcoded in most browsers, so you won't be able to rename or add version to this file. Set expires for favicon to 1-2 month.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With