Skip to content

Make cache expiration responsive to HTTP headers #48

@bchelli

Description

@bchelli

Hey @ranm8,

First of all, this is amazing what you did with requestify. Thank you!

So I have an issue regarding the caching mechanism. From what I understand the cache has an expiration defined by the request using the options.cache.expires. What I'm trying to do is to allow the API to set the expiration for the cache using the standard HTTP cache control headers:

  • Cache-Control
  • Expires

In order to do that, I have created a custom cache transporter which is parsing the response headers and:

  • sets the cache if allowed by the API
  • gets the cache if not expired

The problem is this is always overloaded by the global expiration mechanism of requestify.
https://github.com/ranm8/requestify/blob/master/lib/requestify.js#L160

Finally! The actual question:
Could we let the cache transporter handle the expiration of the cache and pass to it the cache config?

Btw, if you want I can create a pull request with my cache transporter.

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions