Skip to content

Commit

Permalink
Merge pull request #310 from Renumics/fix/frontend-fetches-old-files
Browse files Browse the repository at this point in the history
fix: never cache frontend files
  • Loading branch information
neindochoh authored Oct 25, 2023
2 parents ec914f5 + e36c797 commit d810b9a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions renumics/spotlight/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from typing_extensions import Annotated
from fastapi import Cookie, FastAPI, Request, status
from fastapi.datastructures import Headers
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, Response
from fastapi.staticfiles import StaticFiles
Expand Down Expand Up @@ -56,10 +57,23 @@

from renumics.spotlight.dtypes import DTypeMap


CURRENT_LAYOUT_KEY = "layout.current"


class UncachedStaticFiles(StaticFiles):
"""
FastAPI StaticFiles but without caching
"""

def is_not_modified(
self, response_headers: Headers, request_headers: Headers
) -> bool:
"""
Never Cache
"""
return False


class IssuesUpdatedMessage(Message):
"""
Notify about updated issues.
Expand Down Expand Up @@ -207,9 +221,13 @@ async def _(_: Request, problem: Problem) -> JSONResponse:
plugin.activate(self)

try:
# Mount frontend files as uncached,
# so that we always get the new frontend after updating spotlight.
# NOTE: we might not need this if we added a version hash
# to our built js files
self.mount(
"/static",
StaticFiles(packages=["renumics.spotlight.backend"]),
UncachedStaticFiles(packages=["renumics.spotlight.backend"]),
name="assets",
)
except AssertionError:
Expand Down

0 comments on commit d810b9a

Please sign in to comment.