Created
September 7, 2016 11:11
-
-
Save voduytuan/d2e5426e326c055ab4965b6593a25deb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
importScripts('js/sw-toolbox.js'); | |
toolbox.options.debug = false; | |
toolbox.precache(['/']); | |
//FOr homepage, we use fastest so that it update new content for next request | |
toolbox.router.get('/', toolbox.fastest); | |
// The route for the images | |
toolbox.router.get('/js/(.*)', toolbox.cacheFirst, {cache: {name: 'js', maxEntries: 5, maxAgeSeconds: 8640000}}); | |
toolbox.router.get('/css/(.*)', toolbox.cacheFirst, {cache: {name: 'css', maxEntries: 5, maxAgeSeconds: 8640000}}); | |
toolbox.router.get('/imgs/(.*)', toolbox.cacheFirst, {cache: {name: 'imgs'}}); | |
//for api domain | |
var apiorigin = /api\.teamcrop\.com/; | |
// var apiorigin = /api\.teamcrop\.com/; | |
toolbox.router.get(/.*fulldata.*/, toolbox.cacheFirst, {cache: {name: 'fulldata', maxEntries: 20, maxAgeSeconds: 8640000}, origin: apiorigin}); | |
toolbox.router.get(/.*photoavatar.*/, toolbox.cacheFirst, {cache: {name: 'photoavatar', maxEntries: 20, maxAgeSeconds: 8640000}, origin: apiorigin}); | |
var ajaxList = [ | |
/v1\/companies\/init\?/, | |
/v1\/\w+\?.*$/, | |
/v1\/\w+\/\d+\?.*$/, | |
/v1\/\w+\/ids\?.*$/ | |
] | |
for (var i = 0; i < ajaxList.length; i++) { | |
toolbox.router.get(ajaxList[i], toolbox.networkFirst, {cache: {name: 'ajax'}, origin: apiorigin}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment