Last active
December 2, 2017 19:14
-
-
Save arackaf/6762ee8be7e41b74616bd4d46db368c5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // inside your webpack config | |
| const getCache = ({ name, pattern, expires, maxEntries }) => ({ | |
| urlPattern: pattern, | |
| handler: "cacheFirst", | |
| options: { | |
| cache: { | |
| maxEntries: maxEntries || 500, | |
| name: name, | |
| maxAgeSeconds: expires || 60 * 60 * 24 * 365 * 2 //2 years | |
| }, | |
| successResponses: /0|[123].*/ | |
| } | |
| }); | |
| // .... | |
| new SWPrecacheWebpackPlugin({ | |
| mergeStaticsConfig: true, | |
| filename: "service-worker.js", | |
| staticFileGlobs: [ | |
| "static/bootstrap/css/bootstrap-booklist-build.css", | |
| "static/fontawesome/css/font-awesome-booklist-build.css", | |
| "static/fontawesome/fonts/fontawesome-webfont.woff2", | |
| "static/main-icon2.png", | |
| "util/babelHelpers.min.js" | |
| ], | |
| ignoreUrlParametersMatching: /./, | |
| stripPrefixMulti: { | |
| "static/": "react-redux/static/", | |
| "util/": "react-redux/util/", | |
| "offline.htm": "react-redux/offline.htm" | |
| }, | |
| runtimeCaching: [ | |
| getCache({ pattern: /^https:\/\/images-na.ssl-images-amazon.com/, name: "amazon-images1" }), | |
| getCache({ pattern: /^https:\/\/ecx.images-amazon.com/, name: "amazon-images2" }), | |
| getCache({ pattern: /^https:\/\/s3.amazonaws.com\/my-library-cover-uploads/, name: "local-images1" }), | |
| getCache({ pattern: /book\/searchBooks/, name: "book-search", expires: 60 * 7 }), //7 minutes | |
| getCache({ pattern: /book\/loadDetails/, name: "book-details" }) | |
| ] | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment