I have a static content to cache using nodejs, as far I know there are two ways:
This can be done using nodejs:
app.use(express.static(path.join(__dirname, 'public'), { maxAge: oneDay }));
Add x.appcahe file with static contents to cache, then add manifest attribute in html tag:
<html manifest="x.appcache">
So my question is what is the diffrence between both ways?
If you search for "cache-control vs html manifest" you'll find a TON of details that exceed what can be written by me in a single answer. However, this other question titled HTML 5 Cache Manifest Vs. Etags, Expires or cache-control header has a great summary and to quote
The main differences between the HTML5 cache manifest vs. the traditional HTTP headers:
- for the cache manifest you need support in the browser
- for the HTTP headers you also need support in the browser of course but it's more universal
- you have more control over the caching with cache manifest
- your website or Web app can work correctly offline with no connection at all
- you can have two version of every resource - for offline and online usage
The last point is very handy and lets you easily swap parts of your website that need connection with eg. placeholders containing optional comments that the user doesn't get full functionality without the connection or whatever you want.
There are also some compatibility issues because some browsers don't always play according to the standards...so that's also worth researching and determining which (cache-control vs manifests) is best for your situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With