Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Sep 12, 2023
2 parents bfa426a + 40ea287 commit 25cbc5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
app = Flask(__name__, static_url_path='')
app.url_map.strict_slashes = False # Ignore trailing slashes in URLs
app.json = JinjaCompatibleJsonProvider(app)

# Most files should be loaded through the CDN which has its own caching period and invalidation.
# Use 5 minutes as a reasonable default for all files we load elsewise.
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = datetime.timedelta(minutes=5)

babel = Babel(app)

jinja_partials.register_extensions(app)
Expand Down Expand Up @@ -2245,6 +2250,9 @@ def try_parse_int(x):
# own file loading routines also hot-reload.
utils.set_debug_mode(not os.getenv('NO_DEBUG_MODE'))

# For local debugging, fetch all static files on every request
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = None

# If we are running in a Python debugger, don't use flasks reload mode. It creates
# subprocesses which make debugging harder.
is_in_debugger = sys.gettrace() is not None
Expand Down
1 change: 1 addition & 0 deletions website/cdn.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ def _send_static_file(self, filename):
"""
response = self.app.send_static_file(filename)
response.headers["Access-Control-Allow-Origin"] = "*"
response.cache_control.no_cache = None
response.cache_control.max_age = 24 * 3600 # A day
return response

0 comments on commit 25cbc5b

Please sign in to comment.