Skip to content

Commit

Permalink
chore(pwa): cache fonts and css at google requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Mar 21, 2022
1 parent 958643d commit 82e2141
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/better-write-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="google-site-verification" content="g3Sv5vbTY0qPQyuRyjR322G-PV1A5hD9pQ3EN3lWKpI" />
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
Expand Down
2 changes: 1 addition & 1 deletion packages/better-write-app/src/use/populate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export const usePopulate = () => {
},
},
switcher: {
cover: false,
cover: true,
main: false,
footer: true,
header: false,
Expand Down
49 changes: 47 additions & 2 deletions packages/better-write-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,22 @@ export default defineConfig({
vitePWA({
base: '/',
registerType: 'prompt',
includeAssets: ['favicon.svg', 'favicon.ico', 'robots.txt', 'sitemap.xml', 'browserconfig.xml', 'apple-touch-icon.png', 'three/*.png', 'logo_ascend.svg', 'logo_default.svg', 'logo_harmonic.svg', 'logo_rise.svg', 'logo_desktop.png', 'logo.png', 'logo.svg'],
includeAssets: [
'favicon.svg',
'favicon.ico',
'robots.txt',
'sitemap.xml',
'browserconfig.xml',
'apple-touch-icon.png',
'three/*.png',
'logo_ascend.svg',
'logo_default.svg',
'logo_harmonic.svg',
'logo_rise.svg',
'logo_desktop.png',
'logo.png',
'logo.svg'
],
manifest: {
name: 'Better Write',
short_name: 'Better Write',
Expand All @@ -71,7 +86,37 @@ export default defineConfig({
]
},
workbox: {
sourcemap: false
sourcemap: false,
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365
},
cacheableResponse: {
statuses: [0, 200]
}
}
},
{
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'gstatic-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365
},
cacheableResponse: {
statuses: [0, 200]
},
}
}
]
}
})
],
Expand Down

0 comments on commit 82e2141

Please sign in to comment.