应用程序缓存和404/500 页

发布于 2025-01-03 11:08:51 字数 586 浏览 2 评论 0原文

我有一个看起来像这样的清单:

CACHE MANIFEST
# e4a75fb378cb627a0d51a80c1cc5684c2d918d93e267f5854a511aa3c8db5b1a
/a/application.js
/a/application.css

NETWORK:
*

FALLBACK:
/ /offline/redirect

问题是我的 /404.html 和 /500.html 页面(显然提供了 404 和 500 的响应代码)正在触发回退。它们的行为就像服务器离线一样。

我的问题有两个:

  1. 为什么 /404.html 会触发回退,而 /events 不会?
  2. 如何允许 /404.html 和 /500.html 不触发回退,同时仍然允许 /

触发它。

对于它的价值,我已经尝试过:

NETWORK:
*
/404.html
/500.html

...但是,由于这些页面使用非 200 响应代码提供服务,因此它会触发应用程序缓存错误回调,并且不会保存缓存。

谢谢!

I have a manifest that looks somethin like this:

CACHE MANIFEST
# e4a75fb378cb627a0d51a80c1cc5684c2d918d93e267f5854a511aa3c8db5b1a
/a/application.js
/a/application.css

NETWORK:
*

FALLBACK:
/ /offline/redirect

The issue is that my /404.html and /500.html pages (that are obviously served up with a response code of 404 and 500) are triggering the fallback. They both act just as if the server is offline.

My question is twofold:

  1. Why does /404.html trigger the fallback when /events doesn't?
  2. How can I allow /404.html and /500.html to not trigger the fallback while still allowing / to

trigger it.

For what it's worth, I've already tried this:

NETWORK:
*
/404.html
/500.html

... however since those pages are served w/ a non-200 response code, it triggers the app cache error callback and the cache isn't saved.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹏半生如梦愿梦如真 2025-01-10 11:08:51

对我有用的方法:

  • 从 NETWORK 声明中删除 *
  • 重定向到 /404.html (等)而不是就地渲染。

因此,使用上面的示例:/teams/1241231 302 重定向到 /404.html,它返回 404 状态代码。

What worked for me:

  • Remove * from the NETWORK declaration
  • Redirect to /404.html (et al) instead of rendering in place.

So using the example above: /teams/1241231 302 redirect to /404.html which returns a 404 status code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文