gpt4 book ai didi

angular - service worker 和 sw precache with angular universal

转载 作者:太空狗 更新时间:2023-10-29 17:00:14 27 4
gpt4 key购买 nike

我将 sw precache 与 service worker 一起使用。我在 service worker 中只缓存了浏览器文件夹。因此服务器端渲染在 service worker 中不起作用。任何人都可以帮助我解决这个问题。如果 ssr 工作 service worker 不工作,反之亦然

下面是我的sw预缓存config.json

module.exports = {
navigateFallback: '/index.html',
stripPrefix: 'dist/browser',
root: 'dist/browser',
staticFileGlobs: [

'dist/browser/index.html',
'dist/browser/**.js',
'dist/browser/**.css',
'dist/browser/**.ico',
'dist/browser/assets/images/**.jpg',
'dist/browser/assets/images/**.png',
'dist/browser/assets/images/**.gif',
'dist/browser/assets/js/**/**.js',
'dist/browser/assets/js/**.js',
'dist/browser/assets/css/**.css'


],

runtimeCaching: [{
urlPattern: /^https:\/\/tg\.s3\.rfyfg\.com\//,
handler: 'cacheFirst'
}]
};

谢谢

最佳答案

您可以选择仅将服务器端呈现的内容发送到网络爬虫,以便它们可以为您的页面编制索引以进行搜索引擎优化。

使用 nginx 的示例配置:

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
if ($http_user_agent ~* "whatsapp|googlebot|yahoo|bingbot|baiduspider|yandex|yeti|yodaobot|gigabot|ia_archiver|facebookexternalhit|twitterbot|developers\.google\.com|linkedinbot|discordbot|embedly|quora link preview|slackbot|pinterest|vkShare") {
proxy_pass http://localhost:4000; // your server
break;
}
rewrite . /static/index.html last;
}

关于angular - service worker 和 sw precache with angular universal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50442816/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com