Ionic v6 - Does Ionic use cache-control for its own pages?


I am using Ionic v6 with capacitor.

Because page rendering is slow, especially when a user goes back to a list page (ion-card), I would like to see if it is possible enable browser caching in my app for internal pages - I mean those pages running on localhost - not for an external api.

When user goes back to a list paging it seems like it should be instantaneous if read from browser cache however my guess is that is reading the page again.

As I understand it, Ionic is essentially a website running node.js so browser caching should work.

However, when I run ionic serve and use developer tools to check caching settings it reads - “max-age=0” - no caching and I don’t see a way to send a request for max-age.

Please advise.


You need to show your example code.

It’s more of a configuration question. How do I set the Cache-control and max-age request or response headers in the ionic web server?

There is no “ionic web server”, when you use ionic serve it will run whatever your framework uses under the hood, not something ionic specific, so it depends on the framework you use.
And all of them probably set the max age to 0 because ionic serve is used for live reload, so changes are applied as soon as you change something and save, so if it’s cached you won’t see the changes.

Once you deploy your app to the app stores the assets are local, not served from a web server neither. If you also deploy your app content to a web server, then it’s up to you how do you want to configure it.