Skip to content

Commit f7f3475

Browse files
authored
Merge pull request #509 from julianpoy/fix-api-cache-2
Fix service worker path regex
2 parents 9d90b3e + 3956837 commit f7f3475

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Frontend/src/service-worker.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ workbox.precaching.precacheAndRoute([]);
1111
// Index should be cached networkFirst - this way, users will always get the newest application version
1212
const MAX_OFFILE_APP_AGE = 30; // Days
1313
workbox.routing.registerRoute(
14-
new RegExp('/index\.html'),
14+
new RegExp('/index\\.html'),
1515
workbox.strategies.networkFirst({
1616
cacheName: 'base-asset-cache',
1717
plugins: [
@@ -25,7 +25,7 @@ workbox.routing.registerRoute(
2525
// Icons should be served cache first - they almost never change, and serving an old version is accepable
2626
const MAX_SVG_ICON_AGE = 60; // Days
2727
workbox.routing.registerRoute(
28-
new RegExp('/svg/.*\.svg'),
28+
new RegExp('/svg/.*\\.svg'),
2929
workbox.strategies.cacheFirst({
3030
cacheName: 'svg-icon-cache',
3131
plugins: [
@@ -38,9 +38,9 @@ workbox.routing.registerRoute(
3838

3939
// API calls should always fetch the newest if available. Fall back on cache for offline support.
4040
// Limit the maxiumum age so that requests aren't too stale.
41-
const MAX_OFFLINE_API_AGE = 30; // Days
41+
const MAX_OFFLINE_API_AGE = 60; // Days
4242
workbox.routing.registerRoute(
43-
new RegExp('api\\.recipesage\\.com'),
43+
new RegExp('https://api\\.recipesage\\.com'),
4444
workbox.strategies.networkFirst({
4545
cacheName: 'api-cache',
4646
plugins: [
@@ -54,7 +54,7 @@ workbox.routing.registerRoute(
5454
// S3 assets don't share ID's so we can cache them indefinitely
5555
// Limit the cache to a maximum number of entries so as not to consume too much storage
5656
workbox.routing.registerRoute(
57-
/chefbook.*prod.*s3.*amazonaws/,
57+
new RegExp('https://chefbook-prod.*amazonaws.com/'),
5858
workbox.strategies.cacheFirst({
5959
cacheName: 's3-image-cache',
6060
plugins: [

0 commit comments

Comments
 (0)