Comments (8)
Sounds good!
from http-cache.
Published new versions of the crates today with the custom cache key changes, thanks for your patience on this!
from http-cache.
I've seen the cache modes added and it would be nice if that could be modified on a per request basis. The use case is we only want to cache certain content types. The idea is to to add a closure in an option which if it exists it can be used to check the request and return an updated cache mode for instances where we want to either bypass the cache or use the cache with the default rules. I'll try knocking up a PR with this.
from http-cache.
Looks great, just merged into develop. Thanks again for your contributions!
from http-cache.
Thanks! Glad you found it useful. I'm not against adding something like this, do you have something in mind as far as what the implementation might look like?
from http-cache.
For the customisable cache key I'm thinking of adding another field to CacheOptions
called cache_key
and it is a closure that takes the request and returns the cache key as a String.
With regards to overriding the cache options on a per request basis, I haven't dug much in to it, but the only way I can think of doing this is with a trait implemented for ClientWithMiddleware
with a function which takes CacheOptions
and creates a task_local_extensions::Extensions
with the CacheOptions
and then calls ClientWithMiddleware::execute_with_extensions
with them.
from http-cache.
Think I generally understand what this might look like, would you care to provide a high level overview of the use case for this just so I understand better?
CacheOptions
belongs to the http_cache_semantics
crate, so we would need to add a new field HttpCache
struct or maybe create a new options struct that can contain this CacheOptions
, cache_key
, and any possible future options.
from http-cache.
It's essentially a HTTP proxy which allows configuration for different routes.
Ah I didn't realise it was a re-export, just seen the note in the main http-cache
crate!
I think an addition of another struct to the HttpCache
struct wrapping the CacheOptions
and cache_key
seems ideal and future proof but it is a breaking change. I'll try to draft something up this weekend on the customisable cache_key
first.
from http-cache.
Related Issues (18)
- `url` interaction with redirects HOT 3
- Information about cache hits HOT 12
- Changelog HOT 2
- `Cache-Control: no-cache` header on request not respected? HOT 3
- `CacheManger` not implemented for `MokaManager` HOT 2
- `CACacheManager.path` should be a `PathBuf`, not a `String` HOT 2
- Option to force cache regardless of Cache-Control headers? HOT 13
- Split out client middleware implementations to separate libraries HOT 1
- Enhancement: Store Deserialized HttpResponse for Improved Performance HOT 11
- Add hyper client middleware implementation HOT 10
- Can't use http-cache with un-cloneable requests HOT 6
- Clear-Site-Data header HOT 11
- Cache without storing the response HOT 7
- add WASM support HOT 8
- Error: Middleware(Middleware error: Request object is not cloneable. Are you passing a streaming body? HOT 1
- SQLite manager? HOT 3
- How to manually handle cache expiration? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-cache.