Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

runtimeCaching with client side routing with javascript and html #365

Open
amitvshah25 opened this issue Aug 2, 2018 · 0 comments
Open

Comments

@amitvshah25
Copy link

i have web app with header,footer and content.. my content is similar to app-shell. and i am using page.js for client side routing.. so when user requests page xxx.com/app/example1 .. i load example1.html via jquery.load(..) and so on.. my sw-precache file looks like this..
function writeServiceWorkerFile(cachename,rootDir, handleFetch, callback) { var config = { cacheId: cachename, staticFileGlobs: [ rootDir + '/assets/min/css/**/*.css', //rootDir + '/assets/min/js/lib/**/*.css', rootDir + '/**.html', rootDir + '/assets/images/**.*', rootDir + '/assets/font/**.*', rootDir + '/assets/min/js/**/*.js' ], stripPrefix: rootDir + '/', verbose: false, runtimeCaching:[{ urlPattern:/\/app\//, handler: 'cacheFirst' }], //navigateFallback: 'index.html', navigateFallbackWhitelist: [/^\/app/] }; swPrecache.write(path.join(rootDir, 'service-worker.js'), config, callback) }

when i see the page.. it loads example1.html from service worker cache.. which works fine..
my example1.html looks like

<script type="text/javascript" src="assets/min/js/modules/xxx/findDetails.js"></script> <script type="text/javascript" src="assets/min/js/modules/xxx/findMain.js"></script> <script type="text/javascript" src="assets/min/js/modules/xxx/findResults.js"></script>

css files in example1.html gets loaded from cache.. but javascript files which are included in example1.html dont get loaded from cache.. how can i make sure they gets loaded from cache as well.. when i see service-worker under developer console --> application --> cache storage.. i see all above 3 js files are there..

i dont know what am i missing here.. do i need to set up custom-handler.js and use that ??

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant