diff --git a/changelog.md b/changelog.md index e782e7b..1edd048 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-02-03 - 3.0.56 - fix(cachemanager) +Adjust cache control headers and fix redundant code + +- Remove duplicate assetbroker URLs in the cache evaluation logic. +- Update cache control headers to improve caching behavior. +- Increase the timeout for fetch operations to improve compatibility. + ## 2025-01-28 - 3.0.55 - fix(server) Fix response content manipulation for HTML files with injectReload diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index ba2239d..7d978fe 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@api.global/typedserver', - version: '3.0.55', + version: '3.0.56', description: 'A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.' } diff --git a/ts_web_serviceworker/classes.cachemanager.ts b/ts_web_serviceworker/classes.cachemanager.ts index 3d8ebf4..dfd87c4 100644 --- a/ts_web_serviceworker/classes.cachemanager.ts +++ b/ts_web_serviceworker/classes.cachemanager.ts @@ -98,8 +98,6 @@ export class CacheManager { !originalRequest.url.includes('/api/') && !originalRequest.url.includes('smartserve/reloadcheck'))) || originalRequest.url.includes('https://assetbroker.') || - originalRequest.url.includes('https://assetbroker.') || - originalRequest.url.includes('https://assetbroker.') || originalRequest.url.includes('https://unpkg.com') || originalRequest.url.includes('https://fonts.googleapis.com') || originalRequest.url.includes('https://fonts.gstatic.com') @@ -150,9 +148,11 @@ export class CacheManager { headers.set(key, value); } }); - headers.set('Cache-Control', 'no-cache, no-store, must-revalidate'); + // Prevent browser caching while allowing service worker caching + headers.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate'); headers.set('Pragma', 'no-cache'); headers.set('Expires', '0'); + headers.set('Surrogate-Control', 'no-store'); await cache.put(matchRequest, new Response(responseToPutToCache.body, { ...responseToPutToCache, headers @@ -215,7 +215,7 @@ export class CacheManager { // lets get a new response for comparison const clonedRequest = requestArg.clone(); - const response = await plugins.smartpromise.timeoutWrap(fetch(clonedRequest), 1000); + const response = await plugins.smartpromise.timeoutWrap(fetch(clonedRequest), 5000); // Increased timeout for better mobile compatibility if (response && response.status >= 200 && response.status < 300) { await runtimeCache.delete(requestArg); await runtimeCache.put(requestArg, response);