PWA with multiple pages

我只是一个虾纸丫 提交于 2019-12-05 10:22:25

There's some guidance about possible options in this blog post.

Given your current setup, and your stated desire not to overhaul your architecture too much, I'd recommend trying to add in a service worker implementation that cached your header, footer, and dynamic content separately. The service worker could then concatenate the header (from the cache) + content body (retrieved via fetch() or potentially from the cache) + footer, and return the complete HTML document as the response.

You would need to start exposing your partial HTML header + footer as resources with unique URLs that could be precached, which you're probably not doing right now, and you'd also have to expose just the content body for a given page via a unique URL, and ensure that they're all in a format that could just be concatenated without requiring any complex templating logic.

So it is some extra work, but it does not involve rewriting anything for clients that don't support service workers, and your site would continue to look and behave the same for those clients.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!