Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Good tutorial, Mateusz.
But say I’ve made a change to a .css or .js file, or edited a few image files. Do I now have to change the expires directives for those types so my users get the latest versions? Or will appending a version parameter ( image.jpg?v=123 ) do the trick?
Or is there an easy way to invalidate the browser cache in one simple step?
wonderful tutorial. thanks. i have few questions though…
what if i have fastcgi enabled? when i set epoch will it check in fastcgi cache first or directly in origin?
and how can i cache html for a certain time. eg: 1 day with must re-validate? so that it will check if the file has been updated or not within that 1 day period.
and for other static files, like js/css can i set access_log & log_not_found off from here or i need to create another location inside server block for that?
@mati on the second part, you said by using nginx header module browser dont ask server if the resources has been modified or not before the cache period expires.
i did exactly as per your tutorial, but today i found out that when refreshing my site in firefox, all static resources are having 304 Not-modified header.
i dont understand where i did wrong. but seems your tutorial is working for other parts as expire duration is exact what i define in expires. i tested changing the duration and it change accordingly.
please explain the header 304 not-modified part.
This comment has been deleted
Great tutorial very easy!
But how do i add cache control for: glyphicons-halflings-regular.woff2 (expiration not specified)
I already tried font/woff2 application/x-font-woff2
but google pagespeed keeps complaining
Thanks for the great article. I am facing an issue to enable the expires header for .ttf files. Can you please suggest something. Thanks again.
Am I the only one who this crashes the server for ? It seems when I add the expires directive, I can no longer restart the nginx service. This is the error I get:
nginx: [emerg] “expires” directive invalid value in /etc/nginx/sites-enabled/default:36 nginx: configuration file /etc/nginx/nginx.conf test failed
Hi,
This tutorial doesn’t work for me. I am running 1.10.3 on ubuntu 16.04.5. Nginx doesn’t have any errors but I do not see the expires or cache-control details.
Thanks
Thanks dude, very clear and concise, and worked from the first try. My site now got a grade up on the performance report, thanks you!