Created
August 25, 2023 21:46
-
-
Save aKamrani/ac775236f17c2d02e7d6978661ba02ca to your computer and use it in GitHub Desktop.
set nginx no cache only for HTML/Document type files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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