Skip to content

Instantly share code, notes, and snippets.

@aKamrani
Created August 25, 2023 21:46
Show Gist options
  • Select an option

  • Save aKamrani/ac775236f17c2d02e7d6978661ba02ca to your computer and use it in GitHub Desktop.

Select an option

Save aKamrani/ac775236f17c2d02e7d6978661ba02ca to your computer and use it in GitHub Desktop.
set nginx no cache only for HTML/Document type files
location / {
if ( $uri = '/index.html' ) {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
expires off;
}
if ($http_accept ~* "text/html") {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
expires off;
}
}
# kill cache
proxy_set_header Last-Modified $date_gmt;
proxy_set_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off; # also can use: expires -1;
etag off;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment