Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

Client: Http cache support (experimental) #14

Closed
wants to merge 1 commit into from

Conversation

adamziel
Copy link
Contributor

Adds a CachedClient decorator over Client – it understands HTTP cache headers in the response and writes / reads data to a local file cache.

A few questions still need to be answered:

  • How to handle redirects? Client does that internally at the moment. Ideas: * Internalize cache logic into the Client class * Expose a hook / callback / other extension point from the Client class
  • fetch() is a method on the client class. A decorator means another layer of fetch(). Maybe that's fine, but maybe fetch($client, $request) could be a separate function?
  • Would there be any upside to handling http cache in a read stream instead?

Adds a CachedClient decorator over Client – it understands HTTP cache
headers in the response and writes / reads data to a local file cache.

A few questions still need to be answered:

* How to handle redirects? Client does that internally at the moment.
  Ideas:
     * Internalize cache logic into the Client class
     * Expose a hook / callback / other extension point from the Client
       class
* fetch() is a method on the client class. A decorator means another
  layer of fetch(). Maybe that's fine, but maybe fetch($client,
  $request) could be a separate function?
* Would there be any upside to handling http cache in a read stream
  instead?

private function key( string $url ): string { return sha1( $url ); }

public function body_path( string $url ): string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Either deal with paths or streams, but not both.

@adamziel
Copy link
Contributor Author

Superseded by #18

@adamziel adamziel closed this May 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant