Caching on single page application

As far as i understand. in multi page application we will handle different route on backend so different route will be cache on cloudflare and i set the ttl (this is what i do before with mpa) But now with single page appication. on different route. without the instruction from the backend. will the browser automatically know to use the static html + js from the cloudflare cache? Here is my backend code:
app.get('*', (req, res) => {
const filePath = path.resolve(
__dirname,
'..',
'client',
'build',
'index.html'
);
res.sendFile(filePath);
});
app.get('*', (req, res) => {
const filePath = path.resolve(
__dirname,
'..',
'client',
'build',
'index.html'
);
res.sendFile(filePath);
});
1 Reply
mahiro mahiro mahiro
Because from my belief everytimes it's being acess. it calls to this route in the backend. so when it's going through cloudflare will it knows that it did not have to fetch again from the backend my idea is using wild card like example.com/* in page rule to do this which combine to only one question. Can I return the same file from the cache with different routes? Thank you in advanced! I think i found a way to do it
Want results from more Discord servers?
Add your server