Home HTTP caching in API based application
Reply: 1

HTTP caching in API based application

Axel Published in 2017-12-07 10:54:05Z

Should we use http caching only for static stuff?

Or also in API responses could be using caching headers if data from API is not static? it can be changed by application's users.

Stanislav Bashkyrtsev
Stanislav Bashkyrtsev Reply to 2017-12-07 11:09:53Z

Caching is needed to gain performance but at the same time it increases the likelihood of the data being outdated. It's true for static resources as well. So if your app is under high load and you want to increase the speed - you may sacrifice up-to-date data for gain in performance.

Note, though, that client side needs to respect caching headers. We often work with browsers - they have it all figured out, but if our client is another service, then you need to ensure that it doesn't ignore the headers. This won't be for free - code will need to be written for this to happen.

Your cache may also be public or private. If it's public (any client is allowed to see the content), you may configure a reverse proxy (like nginx) between your server and the clients. Nginx can be set up to cache results (it also understands cache headers). So it may take off some load from your application by not letting requests through and instead returning cached copies.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.334479 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO