mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-23 06:14:00 +08:00
updated caching strategy
This commit is contained in:
parent
5d040ae8a0
commit
9376760fc5
2 changed files with 99 additions and 42 deletions
|
@ -47,20 +47,47 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"source": "**/*.@(jpg|jpeg|gif|png|svg|webp|js|css|eot|otf|ttf|ttc|woff|woff2|font.css|wav|txt)",
|
||||
"source": "**/*.@(jpg|jpeg|gif|png|svg)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Cache-Control",
|
||||
"value": "max-age=604800"
|
||||
"value": "max-age=31536000"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"source": "**/*.@(json)",
|
||||
"source": "**/*.@(eot|otf|ttf|ttc|woff|woff2)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Cache-Control",
|
||||
"value": "max-age=7200"
|
||||
"value": "max-age=31536000"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"source": "**/*.@(json|wav|txt|css)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Cache-Control",
|
||||
"value": "max-age=3600"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"source": "**/*.min.@(js|css)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Cache-Control",
|
||||
"value": "max-age=31536000"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"source": "**/*.????????.@(js|css)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Cache-Control",
|
||||
"value": "max-age=31536000"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -82,48 +82,78 @@ const PRODUCTION_CONFIG = {
|
|||
//include the generated css and js files
|
||||
maximumFileSizeToCacheInBytes: 11000000,
|
||||
exclude: [
|
||||
/html\/.*\.html/,
|
||||
/LICENSE\.txt/,
|
||||
/\.DS_Store/,
|
||||
/\.map$/,
|
||||
/^manifest.*\.js$/,
|
||||
/languages\/.*\.json/,
|
||||
/quotes\/.*\.json/,
|
||||
/themes\/.*\.css/,
|
||||
/challenges\/.*\.txt/,
|
||||
/sound\/.*\.wav/,
|
||||
/images\/.*\.(png|jpg)/,
|
||||
/webfonts\/.+/,
|
||||
// /html\/.*\.html/,
|
||||
// /LICENSE\.txt/,
|
||||
// /\.DS_Store/,
|
||||
// /\.map$/,
|
||||
// /^manifest.*\.js$/,
|
||||
// /languages\/.*\.json/,
|
||||
// /quotes\/.*\.json/,
|
||||
// /themes\/.*\.css/,
|
||||
// /challenges\/.*\.txt/,
|
||||
// /sound\/.*\.wav/,
|
||||
// /images\/.*\.(png|jpg)/,
|
||||
// /webfonts\/.+/,
|
||||
/./,
|
||||
],
|
||||
runtimeCaching: [
|
||||
// {
|
||||
// urlPattern: /.+\.(jpg|jpeg|gif|png|svg)/,
|
||||
// handler: "CacheFirst",
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /.+\.(eot|otf|ttf|ttc|woff|woff2)/,
|
||||
// handler: "CacheFirst",
|
||||
// },
|
||||
// // {
|
||||
// // urlPattern: /.+\.(json|wav|txt|css)/,
|
||||
// // handler: "NetworkFirst",
|
||||
// // },
|
||||
// {
|
||||
// urlPattern: /.+\.min\.(js|css)/,
|
||||
// handler: "CacheFirst",
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /.+\..{8}\.(js|css)/,
|
||||
// handler: "CacheFirst",
|
||||
// },
|
||||
{
|
||||
urlPattern: /languages\/.*\.json/,
|
||||
handler: "StaleWhileRevalidate",
|
||||
},
|
||||
{
|
||||
urlPattern: /quotes\/.*\.json/,
|
||||
handler: "StaleWhileRevalidate",
|
||||
},
|
||||
{
|
||||
urlPattern: /themes\/.*\.css/,
|
||||
handler: "StaleWhileRevalidate",
|
||||
},
|
||||
{
|
||||
urlPattern: /challenges\/.*\.txt/,
|
||||
handler: "StaleWhileRevalidate",
|
||||
},
|
||||
{
|
||||
urlPattern: /sound\/.*\.wav/,
|
||||
handler: "StaleWhileRevalidate",
|
||||
},
|
||||
{
|
||||
urlPattern: /images\/.*\.(png|jpg)/,
|
||||
handler: "StaleWhileRevalidate",
|
||||
},
|
||||
{
|
||||
urlPattern: /webfonts\/.+/,
|
||||
handler: "CacheFirst",
|
||||
urlPattern: /.+/,
|
||||
handler: "NetworkFirst",
|
||||
},
|
||||
|
||||
// {
|
||||
// urlPattern: /languages\/.*/,
|
||||
// handler: "StaleWhileRevalidate",
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /quotes\/.*/,
|
||||
// handler: "StaleWhileRevalidate",
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /themes\/.*/,
|
||||
// handler: "StaleWhileRevalidate",
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /challenges\/.*/,
|
||||
// handler: "StaleWhileRevalidate",
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /layouts\/.*/,
|
||||
// handler: "StaleWhileRevalidate",
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /sound\/.*\.wav/,
|
||||
// handler: "StaleWhileRevalidate",
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /images\/.*\.(png|jpg)/,
|
||||
// handler: "StaleWhileRevalidate",
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /webfonts\/.+/,
|
||||
// handler: "CacheFirst",
|
||||
// },
|
||||
],
|
||||
}),
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue