Skip to content

Commit

Permalink
Merge pull request #36 from jkfran/max-age
Browse files Browse the repository at this point in the history
Set max-age to a year for static files
  • Loading branch information
jkfran authored Nov 23, 2020
2 parents 232cbeb + 7dda719 commit 699cc34
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.7.1 (2020-11-23)

### Added
Changed `SEND_FILE_MAX_AGE_DEFAULT` back to the default value
Set `Cache-Control: max-age 31536000` for requests with the v in the query string

# 0.7.0 (2020-11-18)

### Added
Expand Down
5 changes: 4 additions & 1 deletion canonicalwebteam/flask_base/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def set_cache_control_headers(response):
response.headers[
"Cache-Control"
] = "public, max-age=300, stale-while-revalidate=360"
elif (
flask.request.path.startswith("/static") and "v" in flask.request.args
):
response.headers["Cache-Control"] = "public, max-age=31536000"

return response

Expand All @@ -48,7 +52,6 @@ def __init__(
self.service = service

self.config["SECRET_KEY"] = os.environ["SECRET_KEY"]
self.config["SEND_FILE_MAX_AGE_DEFAULT"] = 31536000

self.url_map.strict_slashes = False
self.url_map.converters["regex"] = RegexConverter
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="canonicalwebteam.flask-base",
version="0.7.0",
version="0.7.1",
description=(
"Flask extension that applies common configurations"
"to all of webteam's flask apps."
Expand Down

0 comments on commit 699cc34

Please sign in to comment.