nginx config
Some checks failed
parsley/pipeline/head There was a failure building this commit

This commit is contained in:
Dan Elbert 2021-12-31 13:14:05 -06:00
parent df2ccf86b2
commit 8ebafd8bae
2 changed files with 26 additions and 12 deletions

View File

@ -5,13 +5,14 @@ upstream parsley_app {
server {
listen 80;
root /parsley/public;
root /parsley/dist;
location / {
try_files $uri @rails;
index index.html index.htm;
try_files $uri $uri/ @rails;
}
location ~ ^/(assets|packs)/ {
location ~ ^/(css|img|js)/ {
try_files $uri @rails;
gzip_static on;
expires 1y;
@ -27,4 +28,4 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}

View File

@ -1,7 +1,12 @@
import { NetworkFirst, StaleWhileRevalidate } from 'workbox-strategies';
import { NetworkFirst, NetworkOnly, StaleWhileRevalidate } from 'workbox-strategies';
import { BroadcastUpdatePlugin } from 'workbox-broadcast-update/BroadcastUpdatePlugin';
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching';
import { defaultHandler, registerRoute } from 'workbox-routing';
import { setDefaultHandler, registerRoute } from 'workbox-routing';
import { setCacheNameDetails } from 'workbox-core';
setCacheNameDetails({
prefix: 'parsley'
});
cleanupOutdatedCaches();
precacheAndRoute(self.__WB_MANIFEST);
@ -10,10 +15,18 @@ const isStaleWhileRevalidate = ({ request }) => {
return request.headers.get('Cache-Then-Network') === 'true';
};
registerRoute(isStaleWhileRevalidate, new StaleWhileRevalidate({
plugins: [
new BroadcastUpdatePlugin()
]
}));
registerRoute(
isStaleWhileRevalidate,
new StaleWhileRevalidate({
plugins: [
new BroadcastUpdatePlugin()
]
})
);
defaultHandler(new NetworkFirst());
registerRoute(
new RegExp('^(?!http).+'),
new NetworkOnly()
);
setDefaultHandler(new NetworkFirst());