-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve caching strategy for static assets with content hash
- Loading branch information
1 parent
e63453b
commit 0db60d8
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
FROM nginx:alpine | ||
ADD ./dist /usr/share/nginx/html | ||
ADD ./dist /usr/share/nginx/html | ||
ADD ./nginx /etc/nginx/conf.d |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html; | ||
|
||
# Default caching strategy based on the etag feature (for stuff like index.html and site.webmanifest that don't have a content hash in the name) | ||
etag on; | ||
add_header Cache-Control "no-cache"; | ||
|
||
# Caching strategy for static assets (Vue build those assets with a content hash in the name, so etag is not usefull and the cache will busted automatically if the content of the file change) | ||
location ~ ((\/css)|(\/js)|(\/img)) { | ||
etag off; | ||
add_header Cache-Control "public,max-age=31536000,immutable"; | ||
} | ||
} | ||
} |