Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache the ‘latest’ version of a pod. #148

Open
alloy opened this issue Sep 16, 2015 · 4 comments
Open

Cache the ‘latest’ version of a pod. #148

alloy opened this issue Sep 16, 2015 · 4 comments

Comments

@alloy
Copy link
Member

alloy commented Sep 16, 2015

The /api/v1/pods/:name/specs/latest endpoint is always performing a complicated query to figure out what the latest version is. Instead of that complicated query, we should probably just cache what the latest version is on the Pod model.

@alloy
Copy link
Member Author

alloy commented Sep 16, 2015

  • Update cached version on push
  • Update cached version on delete/deprecation
  • Set HTTP cache headers appropriately to minimize hitting the app/db even more
  • Do a data migration to add it for all the existing pods

Others?

@orta
Copy link
Member

orta commented Sep 16, 2015

yeah, a cached lastest version is a good idea, in the website we've done a lot of trickery to work around this slowness.

@espadrine
Copy link

Currently shields.io calls https://trunk.cocoapods.org/api/v1/pods/SPEC/specs/latest.

We cache everything in a LRU, and use the cache:

  • when the vendor times out
  • when the cache was updated within 5 seconds or whatever the vendor's Cache-Control header's max-age says
  • when the data changes so infrequently that 75% of responses stay accurate — although in that latter case, we still call the vendor afterwards to keep data up-to-date.

I would love to discuss what better suits vendors cache-wise, as they may have better information about how often a piece of information will be updated than my heuristics.

As I said, we read Cache-Control. It seems that respecting If-Modified-Since would be good. My cache has timestamps, so I could send If-Modified-Since. Is it faster to find out when your internal data was last updated than it is to extract the version inside it?

@alloy
Copy link
Member Author

alloy commented Sep 17, 2015

@espadrine Thanks for the info! I’ll get back to you once I’ve had the time to investigate what the best approach for us is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants