GithubHelp home page GithubHelp logo

kwvanderlinde / python-cached-requests Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 35 KB

Memory-efficient caching for the requests library and Python 3

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

python-cached-requests's People

Contributors

kwvanderlinde avatar

Watchers

 avatar

python-cached-requests's Issues

Add ETag support

The current implementation is not aware of ETag at all, though it naturally stores ETag along with the rest of the headers. The CachedHTTPAdapter should be updated to add an If-None-Match to requests when the current cache entry is stale.

Note that the Cache interface is not sufficient for caches to implement time-based expiry, especially when combined with the desire to use the ETag to validate a stale entry. This is deliberate, as caches should not be altering requests, which is necessary with ETag. Instead, the adapter will check whether the CacheEntry returned by a cache is stale or not, and use the ETag if it is present.

Another option is to enhance the Cache interface. We could add a stale member to CacheEntry to indicate whether the entry is stale or not, as determined by the cache implementation. It would still be up to the adapter to make use of this information properly, and to delete any invalidated entries.

Implement proper logging.

The current state of logging is awful. In some places, we simply print(...) messages, which is unacceptable for a library to do. Elsewhere, we simply have # TODO ... comments instructing us to log certain cases. In other places yet, we have comments that could be replaced with INFO logs that provide the same value, but can produce output on execution.

Complete the HTTP-aware caching.

The HttpAwareCache is missing some crucial parts. In particular, Cache-Control is not processed at all. We should rectify this with an implementation that respects Cache-Control.

Case-insensitive headers

When dealing with headers in the cache and adaptor, we do not respect the case-insensitive nature of header names. We should use a strategy that permits proper lookup of header values regardless of case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.