Merge pull request #2453 from krzotr/patch-7

Fixed `Cache-Control` for .js and .css files - 10 minutes cache
This commit is contained in:
ZeroNet 2020-03-02 18:25:16 +01:00 committed by GitHub
commit 7bf790003e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -299,9 +299,6 @@ class UiRequest(object):
headers["Access-Control-Allow-Headers"] = "Origin, X-Requested-With, Content-Type, Accept, Cookie, Range"
headers["Access-Control-Allow-Credentials"] = "true"
if content_type in ("text/plain", "text/html", "text/css", "application/javascript", "application/json", "application/manifest+json"):
content_type += "; charset=utf-8"
# Download instead of display file types that can be dangerous
if re.findall("/svg|/xml|/x-shockwave-flash|/pdf", content_type):
headers["Content-Disposition"] = "attachment"
@ -312,6 +309,9 @@ class UiRequest(object):
content_type in ("application/javascript", "text/css")
)
if content_type in ("text/plain", "text/html", "text/css", "application/javascript", "application/json", "application/manifest+json"):
content_type += "; charset=utf-8"
if status in (200, 206) and cacheable_type: # Cache Css, Js, Image files for 10min
headers["Cache-Control"] = "public, max-age=600" # Cache 10 min
else: