Skip to content

Commit

Permalink
Disable staticfile compression
Browse files Browse the repository at this point in the history
  • Loading branch information
MWedl committed Oct 29, 2024
1 parent 9b19be7 commit d38ca33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Upcoming
* Experimental plugin system
* Disable static file compression


## v2024.81 - 2024-10-25
* Fix mermaid diagram labels not rendered
* Disable CSP trusted types enforcement because of incompatibilities
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ FROM --platform=$BUILDPLATFORM api-test AS api-statics
RUN python3 manage.py collectstatic --no-input --clear
COPY --from=frontend /app/frontend/dist/index.html /app/frontend/dist/static/ /app/api/frontend/static/
RUN mv /app/api/frontend/static/index.html /app/api/frontend/index.html \
&& python3 manage.py collectstatic --no-input --no-post-process \
&& python3 -m whitenoise.compress /app/api/static/ map
&& python3 manage.py collectstatic --no-input --no-post-process

COPY --from=plugin-builder --chown=user:user /app/plugins/ /app/plugins/

Expand Down
11 changes: 5 additions & 6 deletions api/src/reportcreator_api/utils/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ def process_response(self, request, response):

# Cache static files
if request.path.startswith(settings.STATIC_URL) and response.status_code == 200 and not settings.DEBUG:
if any(request.path.endswith(e) for e in ['.html', '.json']) or \
(request.path.startswith(settings.STATIC_URL + 'plugins/') and '/_nuxt/' not in request.path):
# Do not cache for long
cache.patch_cache_control(response, public=True, max_age=2 * 60)
else:
if '/_nuxt/' not in request.path and not any(request.path.endswith(e) for e in ['.html', '.json']):
# Chunk files with unique names. Can be cached for a long time
cache.patch_cache_control(response, public=True, max_age=24 * 3600)
cache.patch_cache_control(response, public=True, max_age=24 * 60 * 60)
else:
# Do not cache for long
cache.patch_cache_control(response, public=True, max_age=1 * 60)
else:
# Do not cache API responses and django views
cache.add_never_cache_headers(response)
Expand Down

0 comments on commit d38ca33

Please sign in to comment.