mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-20 05:31:03 +02:00
DNS: cache-bust dns.js (DNS_STATIC_VERSION), no-cache headers on CloudFlare page
This commit is contained in:
@@ -77,4 +77,29 @@ def firewall_static_context(request):
|
||||
version = int(time.time())
|
||||
return {
|
||||
'FIREWALL_STATIC_VERSION': version
|
||||
}
|
||||
|
||||
|
||||
def dns_static_context(request):
|
||||
"""Cache-busting for DNS static assets (bumps when dns.js changes). Avoids stale JS/layout."""
|
||||
try:
|
||||
from django.conf import settings
|
||||
base = settings.BASE_DIR
|
||||
paths = [
|
||||
os.path.join(base, 'dns', 'static', 'dns', 'dns.js'),
|
||||
os.path.join(base, 'static', 'dns', 'dns.js'),
|
||||
os.path.join(base, 'public', 'static', 'dns', 'dns.js'),
|
||||
]
|
||||
version = 0
|
||||
for p in paths:
|
||||
try:
|
||||
version = max(version, int(os.path.getmtime(p)))
|
||||
except (OSError, TypeError):
|
||||
pass
|
||||
if version <= 0:
|
||||
version = int(time.time())
|
||||
except (OSError, AttributeError):
|
||||
version = int(time.time())
|
||||
return {
|
||||
'DNS_STATIC_VERSION': version
|
||||
}
|
||||
Reference in New Issue
Block a user