3131//! The core types for building HTTP caches:
3232//!
3333//! ```rust
34+ //! # #[cfg(feature = "manager-cacache")]
35+ //! # fn main() {
3436//! use http_cache::{CACacheManager, HttpCache, CacheMode, HttpCacheOptions};
3537//!
3638//! // Create a cache manager with disk storage
4244//! manager,
4345//! options: HttpCacheOptions::default(),
4446//! };
47+ //! # }
48+ //! # #[cfg(not(feature = "manager-cacache"))]
49+ //! # fn main() {}
4550//! ```
4651//!
4752//! ## Cache Modes
4853//!
4954//! Different cache modes provide different behaviors:
5055//!
5156//! ```rust
57+ //! # #[cfg(feature = "manager-cacache")]
58+ //! # fn main() {
5259//! use http_cache::{CacheMode, HttpCache, CACacheManager, HttpCacheOptions};
5360//!
5461//! let manager = CACacheManager::new("./cache".into(), true);
7380//! manager,
7481//! options: HttpCacheOptions::default(),
7582//! };
83+ //! # }
84+ //! # #[cfg(not(feature = "manager-cacache"))]
85+ //! # fn main() {}
7686//! ```
7787//!
7888//! ## Custom Cache Keys
7989//!
8090//! You can customize how cache keys are generated:
8191//!
8292//! ```rust
93+ //! # #[cfg(feature = "manager-cacache")]
94+ //! # fn main() {
8395//! use http_cache::{HttpCacheOptions, CACacheManager, HttpCache, CacheMode};
8496//! use std::sync::Arc;
8597//! use http::request::Parts;
99111//! manager,
100112//! options,
101113//! };
114+ //! # }
115+ //! # #[cfg(not(feature = "manager-cacache"))]
116+ //! # fn main() {}
102117//! ```
103118//!
104119//! ## Maximum TTL Control
105120//!
106121//! Set a maximum time-to-live for cached responses, particularly useful with `CacheMode::IgnoreRules`:
107122//!
108123//! ```rust
124+ //! # #[cfg(feature = "manager-cacache")]
125+ //! # fn main() {
109126//! use http_cache::{HttpCacheOptions, CACacheManager, HttpCache, CacheMode};
110127//! use std::time::Duration;
111128//!
122139//! manager,
123140//! options,
124141//! };
142+ //! # }
143+ //! # #[cfg(not(feature = "manager-cacache"))]
144+ //! # fn main() {}
125145//! ```
126146//!
127147//! ## Response-Based Cache Mode Override
131151//! error responses like rate limits:
132152//!
133153//! ```rust
154+ //! # #[cfg(feature = "manager-cacache")]
155+ //! # fn main() {
134156//! use http_cache::{HttpCacheOptions, CACacheManager, HttpCache, CacheMode};
135157//! use std::sync::Arc;
136158//!
141163//! match response.status {
142164//! // Force cache successful responses even if headers say not to cache
143165//! 200..=299 => Some(CacheMode::ForceCache),
144- //! // Never cache rate-limited responses
166+ //! // Never cache rate-limited responses
145167//! 429 => Some(CacheMode::NoStore),
146168//! // Use default behavior for everything else
147169//! _ => None,
155177//! manager,
156178//! options,
157179//! };
180+ //! # }
181+ //! # #[cfg(not(feature = "manager-cacache"))]
182+ //! # fn main() {}
158183//! ```
159184//!
160185//! ## Content-Type Based Caching
163188//! This is useful when you only want to cache certain types of content:
164189//!
165190//! ```rust
191+ //! # #[cfg(feature = "manager-cacache")]
192+ //! # fn main() {
166193//! use http_cache::{HttpCacheOptions, CACacheManager, HttpCache, CacheMode};
167194//! use std::sync::Arc;
168195//!
198225//! manager,
199226//! options,
200227//! };
228+ //! # }
229+ //! # #[cfg(not(feature = "manager-cacache"))]
230+ //! # fn main() {}
201231//! ```
202232//!
203233//! ## Streaming Support
@@ -1188,6 +1218,8 @@ pub struct CacheAnalysis {
11881218/// # Examples
11891219///
11901220/// ```rust
1221+ /// # #[cfg(feature = "manager-cacache")]
1222+ /// # fn main() {
11911223/// use http_cache::{CacheMode, HttpCache, CACacheManager, HttpCacheOptions};
11921224///
11931225/// let manager = CACacheManager::new("./cache".into(), true);
@@ -1210,6 +1242,9 @@ pub struct CacheAnalysis {
12101242/// manager,
12111243/// options: HttpCacheOptions::default(),
12121244/// };
1245+ /// # }
1246+ /// # #[cfg(not(feature = "manager-cacache"))]
1247+ /// # fn main() {}
12131248/// ```
12141249#[ derive( Debug , Default , Clone , Copy , PartialEq , Eq ) ]
12151250pub enum CacheMode {
0 commit comments