I am completely new to native apps, which might be beneficial for this question.
Due to the service worker effectively caching everything, I believe there is no need to reload the entire webpage when switching pages by clicking on a link. Therefore, my plan is to only switch the content, use history pushstate to update the URL, and change the title. I have that part all figured out.
However, I am struggling to find resources that support either of the two methods I have in mind for loading content:
- Load center content via AJAX with HTML.
- Load center content as data only and render the HTML using JS.
The first method seems simple but may result in a larger payload.
The second method appears more complex as it would require HTML templates to already be present in the JS. Furthermore, I suspect there might be a way to open a heavily cached page (such as an article) and replace its contents without reloading the whole page. However, I haven't been able to find any resources discussing the pros and cons or offering reliable information on PWA AJAX page switching.
Any insight or credible information on this topic would be greatly appreciated.
EDIT
Despite continuing to research this issue, I have yet to find clear guidance on how to handle dynamic content via AJAX. I am still unsure whether I should convert JSON data to HTML in JS or have it sent as HTML directly from the backend.
In support of the second option, I have realized that my hypothesis had some validity. By utilizing pure.js to fetch an HTML template from a hidden template tag and dynamically generate HTML from JSON via AJAX.