Implement client cache controller for Edgar - #345
Conversation
|
The index files are updated once per day and are heavily used. These can be cached for longer than 10 minutes. I wonder if on balance it should be longer like 30 minutes. We could go longer than that but caching is really for heavy users so who might also want to get new indexes in a timely fashion. |
I also changed the cache rule so it This sounds like a lot, but it's just using the built-in features of Hishel's controller: We're just picking which of the three options is valid for https://github.com/karpetrosyan/hishel/blob/37c0ac2c0159fe281a256d0818c4c9818c98bdf3/hishel/_controller.py#L371-L374
So, within 30 minutes, the controller returns the Response (the cached value). After 30 minutes, it returns the Request (requires revalidation, but will use the cache afterwards). |
The plumbing has been in place for a bit, but without any Edgar specific rules.
Could you take a look at the rules here? Specifically over what paths should/shouldn't be cached, and what cache periods make sense for defaults:
**This cache controller caches, by default:
/submissionsURLs for up to 10 minutes by default, set inMAX_SUBMISSIONS_AGE_SECONDS.*index/.*URLs for up to (edit: changed to 30) 30 minutes by default, set inMAX_INDEX_AGE_SECONDS/Archives/edgar/dataURLs indefinitely (forever)**The implementation is in httpclient_cache.EdgarController.
Note: also added support for swapping in different storage backends. See https://hishel.com/ for usage. To use S3, for instance, create a hishel.S3Storage and hishel.AsyncS3Storage object, and pass to install_cached_client.
Example: