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",