Skip to content

Commit

Permalink
fix: no cache for html file
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-Shen committed Jan 7, 2025
1 parent 9202a65 commit 9258822
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 0 additions & 5 deletions .gitmodules

This file was deleted.

10 changes: 7 additions & 3 deletions labelu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ def __init__(self, *args: Any, **kwargs: Any):

def file_response(self, *args: Any, **kwargs: Any) -> Response:
resp = super().file_response(*args, **kwargs)
resp.headers.setdefault("Cache-Control", self.cachecontrol)
resp.headers.setdefault("Pragma", self.pragma)
resp.headers.setdefault("Expires", self.expires)

# No cache for html files
if resp.media_type == "text/html":
resp.headers.setdefault("Cache-Control", self.cachecontrol)
resp.headers.setdefault("Pragma", self.pragma)
resp.headers.setdefault("Expires", self.expires)

return resp

app.mount("", NoCacheStaticFiles(packages=["labelu.internal"], html=True))
Expand Down

0 comments on commit 9258822

Please sign in to comment.