Skip to content

Client: Http cache support (experimental)#14

Closed
adamziel wants to merge 1 commit intotrunkfrom
http-cache-support
Closed

Client: Http cache support (experimental)#14
adamziel wants to merge 1 commit intotrunkfrom
http-cache-support

Conversation

@adamziel
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Superseded by #18

@adamziel adamziel closed this May 25, 2025
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

Successfully merging this pull request may close these issues.

1 participant