From 0392e3b0334ab81120a9701ef655d488ba44d0f0 Mon Sep 17 00:00:00 2001 From: Mohamadzadeh <7796733@gmail.com> Date: Sun, 25 Oct 2026 19:17:00 +0330 Subject: [PATCH] handle cache for remote ui --- main.py | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 950a190..a24db32 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,22 @@ from functools import partial from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer +from urllib.parse import urlsplit class CORSRequestHandler(SimpleHTTPRequestHandler): def end_headers(self): + # Remote JS files are imported by apps from a stable URL. Disable HTTP + # caching so a full page refresh can pick up a newly deployed version. + # Keep hashed demo assets cacheable and leave non-JS responses unchanged. + path = urlsplit(self.path).path + is_remote_js = path.endswith(".js") and ( + path.count("/") == 1 or path.startswith("/chunks/") + ) + if is_remote_js: + self.send_header("Cache-Control", "no-store, max-age=0") + self.send_header("Pragma", "no-cache") + self.send_header("Expires", "0") + self.send_header("Access-Control-Allow-Origin", "*") self.send_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS") self.send_header( diff --git a/package.json b/package.json index b2882ed..3a5d250 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uikit", - "version": "1.0.0", + "version": "1.1.1", "type": "module", "main": "./dist/index.js", "module": "./dist/index.js",