Spacex-api: Headers request - Add Cache-Control headers to responses

Created on 22 Jun 2020  路  11Comments  路  Source: r-spacex/SpaceX-API

Hi @jakewmeyer

I've noticed no Cache-Control headers have been added to the API responses. Since applications might want to optimise their caching providing the Cache-Control headers could be very useful. Would it be possible to add these? I am for example using Retrofit to make API calls. If Cache-Control is added I can less frequent make calls to the API.

Cheers!
Jeroen

Feature

All 11 comments

How deep do we want to go on this?

Are you just looking for max age?

I'm trying to implement offline caching for looking up data without the need for internet connection so I guess max-age Cache-Control would be fine for now?

Any preference on time? If not, I'll probably just set it based on the existing TTL's for Redis

No preference at the moment. :)

Changes are added and live in v4. Is this something you need in v3?

Would be nice if these can be added to the v3 as well so I can quick add this to my client if it's not that much work. Will migrate to v4 in the upcoming month probably.

Added and live in v3

I noticed the max-age value in the headers is 30 seconds. Is this correct?

For launches, yes. Long enough that the db doesn't get hammered too hard during heavy traffic, yet short enough that time sensitive updates don't take too long.

Hi @jakewmeyer, I was looking into the response headers a bit more and it might be interesting to add an ETag header. This way the API doesn't have to send a full response when the client has a certain version of the requested resource. Interesting enough to apply to the API? Might lower the amount of db queries/api resources.

Added etag support for v3 and v4. However, this only works for conditional GET requests, and while it works great for v3, v4 is much more heavy on POST requests, so this won't do much for that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tearth picture Tearth  路  4Comments

markvital picture markvital  路  4Comments

jesusrp98 picture jesusrp98  路  8Comments

pvegh picture pvegh  路  4Comments

timisenman picture timisenman  路  4Comments