Serve page from cache on navigation back

146 Views Asked by At

Basically what I want is this: https://dev.to/videos

You can select an item -> new page with item loads -> you click on backward button -> the old page is loaded from cache

I want that the same search page shown to user on navigation back, without calling the async fetch method again.

A solution seems to be SPA? But that is an enormous overhead. I know how to do this with SPA. I need way without SPA.

iPhone, Android and Safari have a backforward-cache enabled by default, so no problem there. Static pages also don't have any problems.

I don't need any excact JavaScript code. I just want to know how do other websites solve this problem? Is SPA the only way? Are there any "frameworks" to solve this problem?

1

There are 1 best solutions below

0
HolaPz On

If server allows the page to be cached, your browser won't send a request again before the page expires.

https://stackoverflow.com/a/36554152/14263615