From d0b195c7d02856da2f986e240f47175015fae016 Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Thu, 9 Mar 2023 19:38:43 +0000 Subject: [PATCH] Changed to use etag cache for js and css --- server.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index fbab4e0c..5aba5761 100644 --- a/server.py +++ b/server.py @@ -18,6 +18,14 @@ except ImportError: import mimetypes + +@web.middleware +async def cache_control(request: web.Request, handler): + response: web.Response = await handler(request) + if request.path.endswith('.js') or request.path.endswith('.css'): + response.headers.setdefault('Cache-Control', 'no-cache') + return response + class PromptServer(): def __init__(self, loop): mimetypes.init(); @@ -26,7 +34,7 @@ class PromptServer(): self.loop = loop self.messages = asyncio.Queue() self.number = 0 - self.app = web.Application(client_max_size=20971520) + self.app = web.Application(client_max_size=20971520, middlewares=[cache_control]) self.sockets = dict() self.web_root = os.path.join(os.path.dirname( os.path.realpath(__file__)), "web")