fix(cache): add aggressive no-store middleware, CSP updates, and client-side service worker & cache purge

This commit is contained in:
2026-11-17 11:00:09 +05:30
parent 28dd3beb90
commit d49bd5c721
6 changed files with 95 additions and 5 deletions
+39
View File
@@ -169,6 +169,45 @@ export default function RootLayout({
return (
<html lang="en" className={`${poppinsFont.variable} ${interFont.variable} ${monoFont.variable} font-sans`}>
<head>
<meta httpEquiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta httpEquiv="Pragma" content="no-cache" />
<meta httpEquiv="Expires" content="0" />
<script
dangerouslySetInnerHTML={{
__html: `
(function() {
try {
// 1. Unregister any stale Service Workers on client devices
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for (var i = 0; i < registrations.length; i++) {
registrations[i].unregister();
}
});
}
// 2. Clear stale Cache Storage API entries
if ('caches' in window) {
caches.keys().then(function(keys) {
for (var i = 0; i < keys.length; i++) {
caches.delete(keys[i]);
}
});
}
// 3. Automated cache-bust verification
var BUILD_TAG = '20261117_sfpro_v2';
var cachedTag = localStorage.getItem('__cre_build_tag');
if (cachedTag !== BUILD_TAG) {
localStorage.setItem('__cre_build_tag', BUILD_TAG);
if (cachedTag !== null && window.location.search.indexOf('v=') === -1) {
// Perform clean cache-busting reload once for returning visitors
window.location.replace(window.location.pathname + (window.location.search ? window.location.search + '&' : '?') + 'v=' + Date.now());
}
}
} catch(e) {}
})();
`,
}}
/>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(organizationJsonLd) }}