Przeglądaj źródła

Set Cache-Control on static files with a version tag

pull/65/head
Ben Kurtovic 5 miesięcy temu
rodzic
commit
270ad50cf5
2 zmienionych plików z 11 dodań i 3 usunięć
  1. +1
    -1
      app.py
  2. +10
    -2
      src/copyvios/__init__.py

+ 1
- 1
app.py Wyświetl plik

@@ -86,7 +86,7 @@ def write_access_log(response: Response) -> Response:

@functools.lru_cache
def _get_hash(path: str, mtime: float) -> str:
# mtime is used as part of the cache key
del mtime # mtime is used as part of the cache key
with open(path, "rb") as fp:
return hashlib.sha1(fp.read()).hexdigest()



+ 10
- 2
src/copyvios/__init__.py Wyświetl plik

@@ -3,9 +3,17 @@ import logging
import os
from logging.handlers import TimedRotatingFileHandler

from flask import Flask
from flask import Flask, request

app = Flask(

class CopyviosFlask(Flask):
def get_send_file_max_age(self, filename: str | None) -> int | None:
if request.args.get("v"):
return 365 * 24 * 60 * 60
return super().get_send_file_max_age(filename)


app = CopyviosFlask(
"copyvios",
instance_path=os.getcwd(),
instance_relative_config=True,


Ładowanie…
Anuluj
Zapisz