handle cache for remote ui
This commit is contained in:
parent
03d7307adf
commit
0392e3b033
13
main.py
13
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(
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uikit",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.1",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user