Skip to content

Instantly share code, notes, and snippets.

@VirtuBox
Created June 6, 2017 22:35
Show Gist options
  • Save VirtuBox/2a2f0b56ca119d2fab040e31053ae636 to your computer and use it in GitHub Desktop.
Save VirtuBox/2a2f0b56ca119d2fab040e31053ae636 to your computer and use it in GitHub Desktop.
Nginx - Allow browser cache for static assets

Nginx to set the Expires HTTP header and the max-age directive of the Cache-Control HTTP header of static files

Add the following rules to your nginx configuration

# images, icons, video, audio, css, js
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|css|js)$ {
	expires 1M;
	access_log off;
	add_header Cache-Control "public";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment