HTTP::Promise::Headers::CacheControl - Cache-Control Header Field
use HTTP::Promise::Headers::CacheControl; my $cc = HTTP::Promise::Headers::CacheControl->new || die( HTTP::Promise::Headers::CacheControl->error, "\n" );
v0.1.0
The following is an extract from Mozilla documentation.
The Cache-Control HTTP header field holds directives (instructions) — in both requests and responses — that control caching in browsers and shared caches (e.g. Proxies, CDNs).
Cache-Control
The following known properties can be set with those methods. If you want to remove a property, simply set a value of undef.
undef
When you set a new property, it will be added at the end.
If you want to set or get non-standard property, use the "property" method
This class keeps track of the order of the properties set to ensure repeatability and predictability.
Returns a string representation of the Cache-Control object.
This takes a boolean value. When the value is true, this property is set if it does not already exist, and if false, it is removed.
If no value is provided, it returns true if the property is already set and false if it is not.
The immutable response directive indicates that the response will not be updated while it's fresh.
immutable
Cache-Control: public, max-age=604800, immutable
If a value is provided, this takes an integer, and set the property to that value. If it exists already, it simply change the property value, otherwise it adds it at the end.
When no value is provided, this returns the numeric value of that property if it exists, or an empty string otherwise.
The max-age=N response directive indicates that the response remains fresh until N seconds after the response is generated.
Cache-Control: max-age=604800
This is used in request and in response.
The max-stale=N request directive indicates that the client allows a stored response that is stale within N seconds.
max-stale=N
Cache-Control: max-stale=3600
The min-fresh=N request directive indicates that the client allows a stored response that is fresh for at least N seconds.
min-fresh=N
Cache-Control: min-fresh=600
The must-revalidate response directive indicates that the response can be stored in caches and can be reused while fresh. If the response becomes stale, it must be validated with the origin server before reuse.
must-revalidate
Typically, must-revalidate is used with max-age.
Cache-Control: max-age=604800, must-revalidate
The must-understand response directive indicates that a cache should store the response only if it understands the requirements for caching based on status code.
must-understand should be coupled with no-store for fallback behavior.
Cache-Control: must-understand, no-store
The no-cache response directive indicates that the response can be stored in caches, but the response must be validated with the origin server before each reuse, even when the cache is disconnected from the origin server.
no-cache
Cache-Control: no-cache
The no-store response directive indicates that any caches of any kind (private or shared) should not store this response.
no-store
Cache-Control: no-store
Some intermediaries transform content for various reasons. For example, some convert images to reduce transfer size. In some cases, this is undesirable for the content provider.
no-transform indicates that any intermediary (regardless of whether it implements a cache) shouldn't transform the response contents.
no-transform
The client indicates that cache should obtain an already-cached response. If a cache has stored a response, it's reused.
Returns the array object used by this header field object containing all the properties set.
The private response directive indicates that the response can be stored only in a private cache (e.g. local caches in browsers).
private
Cache-Control: private
Sets or gets an arbitrary property.
$h->property( community => 'UCI' ); my $val = $h->property( 'community' );
See also rfc7234, section 5.2.3
Returns the hash object used as a repository of properties.
The proxy-revalidate response directive is the equivalent of must-revalidate, but specifically for shared caches only.
proxy-revalidate
The public response directive indicates that the response can be stored in a shared cache. Responses for requests with Authorization header fields must not be stored in a shared cache; however, the public directive will cause such responses to be stored in a shared cache.
public
Cache-Control: public
The s-maxage response directive also indicates how long the response is fresh for (similar to max-age) — but it is specific to shared caches, and they will ignore max-age when it is present.
s-maxage
Cache-Control: s-maxage=604800
The stale-if-error response directive indicates that the cache can reuse a stale response when an origin server responds with an error (500, 502, 503, or 504).
stale-if-error
Cache-Control: max-age=604800, stale-if-error=86400
The stale-while-revalidate response directive indicates that the cache could reuse a stale response while it revalidates it to a cache.
stale-while-revalidate
Cache-Control: max-age=604800, stale-while-revalidate=86400
Jacques Deguest <jack@deguest.jp>
See rfc7234, section 5.2, rfc8246, section 2 and Mozilla documentation
HTTP::Promise, HTTP::Promise::Request, HTTP::Promise::Response, HTTP::Promise::Message, HTTP::Promise::Entity, HTTP::Promise::Headers, HTTP::Promise::Body, HTTP::Promise::Body::Form, HTTP::Promise::Body::Form::Data, HTTP::Promise::Body::Form::Field, HTTP::Promise::Status, HTTP::Promise::MIME, HTTP::Promise::Parser, HTTP::Promise::IO, HTTP::Promise::Stream, HTTP::Promise::Exception
Copyright(c) 2022 DEGUEST Pte. Ltd.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install HTTP::Promise, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Promise
CPAN shell
perl -MCPAN -e shell install HTTP::Promise
For more information on module installation, please visit the detailed CPAN module installation guide.