handle cache for remote ui
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 51s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 6s

This commit is contained in:
Mohamadzadeh 2026-10-25 19:17:00 +03:30
parent 03d7307adf
commit 0392e3b033
2 changed files with 14 additions and 1 deletions

13
main.py
View File

@ -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(

View File

@ -1,6 +1,6 @@
{
"name": "uikit",
"version": "1.0.0",
"version": "1.1.1",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",