mirror of https://github.com/scrapy/scrapy.git
Merge 7538718464 into c9446931a8
This commit is contained in:
commit
fd3add9c83
|
|
@ -415,7 +415,7 @@ HttpCacheMiddleware
|
|||
* :ref:`httpcache-policy-dummy`
|
||||
|
||||
You can change the HTTP cache policy with the :setting:`HTTPCACHE_POLICY`
|
||||
setting. Or you can also implement your own policy.
|
||||
setting. Or you can also :ref:`implement your own policy <httpcache-policy-custom>`.
|
||||
|
||||
.. reqmeta:: dont_cache
|
||||
|
||||
|
|
@ -487,6 +487,40 @@ RFC2616 policy
|
|||
* ... probably others ..
|
||||
|
||||
|
||||
.. _httpcache-policy-custom:
|
||||
|
||||
Writing your own policy
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can implement a cache policy by creating a class that
|
||||
defines the methods described below.
|
||||
|
||||
.. module:: scrapy.extensions.httpcache
|
||||
|
||||
.. class:: CachePolicy
|
||||
|
||||
.. method:: should_cache_request(request)
|
||||
|
||||
Return True if the :class:`~scrapy.http.Request` is cacheable otherwise False
|
||||
|
||||
.. method:: should_cache_response(response, request)
|
||||
|
||||
Return True if :class:`~scrapy.http.Response` should be cached otherwise False
|
||||
|
||||
.. method:: is_cached_response_fresh(cachedresponse, request)
|
||||
|
||||
Return True if cached :class:`~scrapy.http.Response` has expired otherwise False
|
||||
|
||||
.. method:: is_cached_response_valid(cachedresponse, response, request)
|
||||
|
||||
Return True if cached :class:`~scrapy.http.Response` is valid otherwise False
|
||||
|
||||
|
||||
In order to use this policy, set:
|
||||
|
||||
* :setting:`HTTPCACHE_POLICY` to the Python import path of your custom policy class.
|
||||
|
||||
|
||||
.. _httpcache-storage-fs:
|
||||
|
||||
Filesystem storage backend (default)
|
||||
|
|
|
|||
Loading…
Reference in New Issue