Which Of The Following Devices Can Also Provide Web Caching Services?
A cacheable response is an HTTP response that Cloud CDN tin can shop and quickly retrieve, thus allowing for faster load times. Not all HTTP responses are cacheable.
Cache modes
With cache modes, you tin can control the factors that make up one's mind whether Cloud CDN caches your content.
Deject CDN offers three cache modes, which define how responses are cached, whether Deject CDN respects cache directives sent by the origin, and how cache TTLs are applied.
The available enshroud modes are shown in the post-obit table:
Cache mode | Beliefs |
---|---|
CACHE_ALL_STATIC | Automatically caches successful responses with static content that aren't otherwise uncacheable. Origin responses that set valid caching directives are also buried. This is the default behavior for Cloud CDN-enabled backends created past using the Google Cloud CLI or the Residual API. |
USE_ORIGIN_HEADERS | Requires successful origin responses to ready valid enshroud directives and valid caching headers. Successful responses without these directives are forwarded from the origin. |
FORCE_CACHE_ALL | Unconditionally caches successful responses, overriding whatever cache directives set by the origin. This way is not appropriate if the backend serves private, per-user content, such as dynamic HTML or API responses. |
Mistake responses may be buried fifty-fifty in the absence of valid cache directives.
Before you set the cache style to FORCE_CACHE_ALL
, consider the following behaviors:
-
For signed URLs or signed cookies,
FORCE_CACHE_ALL
overrides the maximum age specified through the Cache entry maximum age setting in the Google Deject console or thegcloud --signed-url-cache-max-age
choice. -
FORCE_CACHE_ALL
changes the time to alive (TTL) of whatever previously cached content. This change tin can cause some entries that were previously considered fresh (due to having longer TTLs from origin headers) to be considered stale, and it can cause some entries that were previously considered dried to be considered fresh. -
FORCE_CACHE_ALL
overrides cache directives (Cache-Control
andExpires
) merely does not override other origin response headers. In particular, aVary
header is all the same honored, and may suppress caching even in the presence ofFORCE_CACHE_ALL
. For more than information, see Vary headers.
For setup instructions, encounter Setting the cache mode.
Static content
Static content is content that is ever the aforementioned, even when accessed by different users. The CSS that you use to fashion your site, JavaScript to provide interactivity, video, and image content typically don't change for each user for a given URL (cache cardinal), and thus benefit from being buried across Deject CDN's global border network.
When yous ready the enshroud mode to CACHE_ALL_STATIC
, Cloud CDN automatically caches responses for the post-obit:
- Spider web Assets, including CSS (
text/css
), JavaScript (application/javascript
) and all web fonts, including WOFF2 (font/woff2
) - Images, including JPEG (
prototype/jpg
) and PNG (epitome/png
) - Videos, including H.264, H.265, and MP4 (
video/mp4
) +. Audio files, including MP3 (image/mpeg
) and MP4 (audio/mp4
) - Formatted documents, including PDF (
awarding/pdf
)
The post-obit table provides a summary.
Category | MIME types |
---|---|
Web assets | text/css text/ecmascript text/javascript application/javascript |
Fonts | Any Content-Blazon matching font/* |
Images | Any Content-Blazon matching epitome/* |
Videos | Whatever Content-Type matching video/* |
Audio | Whatsoever Content-Type matching audio/* |
Formatted document types | application/pdf and application/postscript |
Deject CDN inspects the Content-Type
HTTP response header, which reflects the MIME type of the content being served.
Note the post-obit:
-
Your origin's spider web server software must set the
Content-Blazon
for each response. Many web servers automatically set theContent-Type
header, including NGINX, Varnish, and Apache. -
Deject Storage sets the
Content-Blazon
header automatically on upload when you use the Cloud console or thegsutil
tool to upload content. -
If a response is cacheable based on its MIME type simply has a
Cache-Control
response header ofprivate
orno-store
, or aSet-Cookie
header (see the full list of rules), it isn't cached.
Cloud CDN doesn't use file extensions in the URL path to determine whether a response is cacheable because many valid cacheable responses aren't reflected in URLs.
If you want to cache text/html
and awarding/json
content types, you must ready explicit Cache-Control
headers in the response, being careful non to accidentally cache one user'southward data and serve information technology to all users.
Cacheable content
Cloud CDN caches responses that meet all of the requirements in this department. Some of these requirements are specified by RFC 7234, and others are specific to Cloud CDN.
Cloud CDN may periodically change the exact ready of conditions under which it caches content. If you want to explicitly forbid Deject CDN from caching your content, follow the guidelines in RFC 7234 to determine how to specify a guaranteed-uncacheable response. Run into also the not-cacheable content based on origin headers section.
Deject CDN stores responses in cache if all of the post-obit are true.
Attribute | Requirement |
---|---|
Served past | Backend service, backend bucket, or an external backend with Cloud CDN enabled |
In response to | Get request |
Condition code | |
Freshness | The response has a For cacheable responses without an age (for example, with With the With the If negative caching is enabled and the status lawmaking matches ane for which negative caching specifies a TTL, the response is eligible for caching, even without explicit freshness directives. |
Content | Contains a valid For example, a |
Size | Less than or equal to the maximum size. For responses with sizes between 10 MB and 5 TB, see the additional cacheability constraints described in byte range requests. |
For Deject Storage backend buckets, following are several means to satisfy these requirements:
-
Make your saucepan publicly readable. This is the approach that we recommend for public content. With this setting, anyone on the internet can view and list your objects and their metadata, excluding ACLs. The recommended exercise is to dedicate specific buckets for public objects. For more information, run into Recommended bucket architecture.
-
Brand the individual objects publicly readable. We don't recommend this approach.
By default, when the entire bucket is public, or the individual objects are public and the individual objects don't specify Cache-Control
metadata, Cloud Storage assigns a Cache-Control: public, max-age=3600
header to the object. You can set different values by using Cache-Command
metadata.
For an example that shows how to configure an external HTTP(S) load balancer with a backend saucepan, come across Setting up Cloud CDN with a backend bucket.
Maximum size
Deject CDN enforces a maximum size for each response. Any response with a body larger than the maximum size is non cached but is nevertheless delivered to the customer.
The maximum size varies depending on whether the origin server supports byte range requests.
Origin server supports byte range requests | Origin server does not support byte range requests |
---|---|
five TB (5,497,558,138,880 bytes) | x MB (x,485,760 bytes) |
Nearly all modern web servers (including NGINX, Apache, and Varnish) support byte range requests.
Non-cacheable content based on origin headers
At that place are checks that cake caching of responses. Cloud CDN may periodically change the verbal set of conditions under which it caches content, so if you want to explicitly preclude Cloud CDN from caching your content, follow the guidelines in the standard (RFC 7234) to determine how to specify a guaranteed-uncacheable response.
Cloud CDN doesn't cache a response if it does non run into the requirements for Cacheable content, or if any of the following is true.
Attribute | Requirement |
---|---|
Served by | Backend service or external backend that doesn't have Deject CDN enabled |
Cookie | Has a Fix-Cookie header |
Vary header | Has a value other than Accept , Have-Encoding , Origin , or X-Origin |
Response directive | Response has a Cache-Control header with the no-store or private directive (unless using the FORCE_CACHE_ALL cache fashion, in which case the Enshroud-Control header is ignored) |
Request directive | Request has a Cache-Control: no-store directive |
Request authorization | Request has an Authorization header, unless overridden past the response Cache-Control. |
Size | Larger than the maximum size |
If Cache-Command: no-store
or private
is present, but the content is still being buried, this is due to one of the following:
- URL signing is configured.
- The Cloud CDN cache mode is gear up to force caching of all responses.
Preventing caching
To prevent private information from being cached in Cloud CDN caches, do the post-obit:
- Make sure that Cloud CDN enshroud mode isn't set to the
FORCE_CACHE_ALL
manner, which unconditionally caches all successful responses. - Include a
Cache-Command: individual
header in responses that should not be stored in Cloud CDN caches, or aCache-Command: no-store
header in responses that should non be stored in any enshroud, even a web browser's enshroud. - Exercise not sign URLs that provide access to private information. When content is accessed by using a signed URL, it is potentially eligible for caching regardless of whatever
Cache-Control
directives in the response. - For origin (enshroud fill) requests that include the
Authorization
request header, Deject CDN only caches responses that include thepublic
,must-revalidate
, ors-maxage
cache control directives when the enshroud mode is prepare toUSE_ORIGIN_HEADERS
orCACHE_ALL_STATIC
. This prevents accidentally caching per-user content and/or content that requires authentication. TheFORCE_CACHE_ALL
cache fashion does non have this restriction.
With custom response headers, you can specify headers that the global external HTTP(S) load balancer (classic) adds to proxied responses. Custom response headers allow yous reflect the cache condition to your clients, client geographic data, and your own static response headers.
For the list of headers, see Variables that tin appear in the header value.
For instructions, see Working with custom response headers.
Custom response headers are not supported for Deject CDN deployments on global external HTTP(Due south) load balancers.
Cache keys
Each enshroud entry in a Cloud CDN cache is identified by a cache key. When a request comes into the cache, the cache converts the URI of the request into a cache key, and and so compares it with keys of cached entries. If it finds a match, the cache returns the object associated with that key.
For backend services, Cloud CDN defaults to using the complete asking URI as the cache key. For instance, https://example.com/images/true cat.jpg
is the complete URI for a particular request for the true cat.jpg
object. This cord is used as the default cache key. Merely requests with this verbal cord friction match. Requests for http://example.com/images/cat.jpg
or https://example.com/images/cat.jpg?user=user1
do not match.
For backend buckets, the default is for the cache key to consist of the URI without the protocol or host. By default, but query parameters that are known to Cloud Storage are included as part of the cache key (for example, "generation").
Thus, for a given backend saucepan, the post-obit URIs resolve to the same cached object:
-
http://case.com/images/cat.jpg
-
https://instance.com/images/true cat.jpg
-
https://example.com/images/cat.jpg?user=user1
-
http://case.com/images/cat.jpg?user=user1
-
https://example.com/images/cat.jpg?user=user2
-
https://media.instance.com/images/true cat.jpg
-
https://www.example.com/images/cat.jpg
You tin can alter which parts of the URI are used in the cache key. While the filename and path must e'er be part of the primal, y'all can include or omit whatever combination of protocol, host, or query cord when customizing your enshroud key. Using cache keys describes how to customize your cache keys.
URI part | Customization | Instance URLs that have the same enshroud central |
---|---|---|
Protocol | Omit the protocol from the cache fundamental. |
|
Host | Omit the host from the cache primal. |
|
Query string | Omit the query cord from the enshroud key. Selectively omit or include portions of the query string. |
|
In addition to including or omitting the entire query string, yous can use portions of the query string by using include lists and exclude lists.
Query string include list
You can selectively control which query string parameters Cloud CDN incorporates into cache keys. For example, if you lot create an include list of user
, thenhttps://instance.com/images/cat.jpg?user=user1&color=blue
creates a cache key of https://example.com/images/cat.jpg?user=user1
that also matches https://instance.com/images/cat.jpg?user=user1&color=red
.
To use this selection, you must include the query string, specify a non-empty include list, and not specify an exclude list.
Query string include list for Cloud Storage cache keys
Including URL query parameters in cache keys for Cloud Storage buckets helps support cache busting. Enshroud busting is the process of allowing a user to find a new version of the file that has been uploaded, even if the old version is still validly cached past TTL.
You can include-list specific query parameters in the cache cardinal used for serving responses from a backend saucepan. Although Cloud Storage does non serve unlike content or route based on query parameters, you can cull to include parameters that allow you to cache-bust static content stored in Cloud Storage buckets.
For example, y'all can append a ?version=VERSION
or ?hash=HASH
query parameter that is based on the underlying content. This limits the need to proactively invalidate content and aligns with modern web development workflows, where web frameworks and URLs use a hash of the content to avoid serving stale objects beyond deployments.
Because including query parameters in the cache key is opt-in only, Cloud CDN doesn't support excluding query parameters from a cache key to a backend bucket.
Query string exclude list
You can selectively control which query string parameters Deject CDN ignores past using an exclude listing. For instance, if you create an exclude list of user
, all query string parameters except user
are used in the cache primal.
With the exclude listing configured and an input of https://example.com/images/cat.jpg?user=user1&color=blueish
, Cloud CDN creates a cache key of https://instance.com/images/cat.jpg?color=blue
that as well matches https://example.com/images/true cat.jpg?user=user2&colour=blue
but not https://example.com/images/cat.jpg?user=user1&color=red
.
To use this option, you must include the query string, specify a not-empty exclude list, and non specify an include list.
Query parameter social club
The generated cache cardinal doesn't depend on the order of the query parameters.
For case, the following query parameters generate the same enshroud key:
-
info=123&variant=13e&geography=U.s.
-
geography=U.s.&variant=13e&info=123
You tin improve enshroud hit rates and origin offload with the post-obit enshroud key configuration settings.
- For backend services and buckets: Apply HTTP headers as part of enshroud keys by including named headers in the cache key configuration.
- For backend services only: Use named HTTP cookies as cache keys, such as for A/B (multivariate) testing, canarying, and similar scenarios.
Cache requests that include additional HTTP headers or HTTP cookies in the request are cached on the third asking in a cache location for that cache fundamental. This reduces the impact of loftier cardinality header/cookie values on your cache eviction rates. Under normal circumstances and user traffic conditions, this should not be noticeable and ensures that popular content remains buried.
To cache additional variations of a response, you lot can include additional request headers in the enshroud fundamental.
Some headers are not allowed in cache keys because they are typically very high cardinality. In well-nigh cases, the values of these headers are either unique per user (Cookie
,Say-so
) or accept thousands of likely values (Referer
, User-Amanuensis
, Accept
). For example, the User-Agent
header can have over 5000 unique values given the large variety of browsers, user-devices, and operating systems. These types of headers would take a astringent negative impact on enshroud striking rates.
Cloud CDN doesn't allow the following headers to be included in the list of headers:
-
Have
-
Have-Encoding
-
Potency
, because this is controlled by configuration (cdnPolicy.includeHost
) -
Authorization
, typically per-user as in OAuthBearer
tokens -
CDN-Loop
-
Connectedness
-
Content-MD5
-
Content-Type
-
Cookie
-
Date
-
Forwarded
, often per-customer or per-proxy -
From
-
Host
, considering this is controlled by configuration (cdnPolicy.includeHost
) -
If-Match
,If-Modified-Since
, orIf-None-Match
-
Origin
-
Proxy-Say-so
-
Range
-
Referer
(orReferrer
) -
User-Amanuensis
-
Desire-Digest
-
X-CSRFToken
andX-CSRF-Token
every bit used past Django and Ruby on Rails -
X-Forwarded-For
, often per-client or per-proxy -
10-User-IP
- Any header starting with the post-obit:
-
Access-Control-
, such equallyAdmission-Control-Request-Headers
andAdmission-Control-Asking-Method
-
Sec-Fetch-
-
Sec-GFE-
-
Sec-Google-
-
X-Amz-
-
X-GFE-
-
X-Goog-
-
Ten-Google-
-
Notes:
- Asking header values are used to generate the cache cardinal earlier whatever additions or modifications performed with custom headers.
- Merely valid HTTP header field names are accepted per RFC 7230.
- Header field names are case-insensitive, and duplicates are rejected.
Suppose the user sends multiple aforementioned-named headers with different header values—for example:
My-Header: Value1 My-Header: Value2
In this case, Cloud CDN modifies the request by assuming that the header must follow the standard convention that allows some headers to have multiple values. Cloud CDN collapses them into a comma-separated list to send to the backend, then it'south as if the customer sent the post-obit:
My-Header: Value1, Value2
Including named cookies
An HTTP cookie is a name=value
pairing, and a request tin can include multiple HTTP cookies, either separated by a semicolon on the same line, or as discrete Cookie
asking headers with one cookie per header.
Yous tin can provide a list of cookie names (upwards to 3).
User agents (such as web browsers) ofttimes limit the number of cookies stored per domain to iv KB; brand sure not to send too many (or too large) cookies, equally the user agent might not send all cookies in a request. This tin impact whether a user receives a specific cached response.
If you are serving your static content from a dissimilar hostname from which you issue cookies, ensure that the Domain
attribute of the cookie (and the Path
) aspect allows the cookie to be sent along with requests for static content.
If a request includes multiple instances of the aforementioned cookie proper noun, simply the first one is honored.
Enshroud control directives
HTTP cache command directives affect Cloud CDN's behavior, as outlined in the following table.
N/A signifies that a directive is non applicable to a request or response.
Directive | Request | Response |
---|---|---|
no-store | When nowadays in a request, Cloud CDN honors this and does not store the response in the enshroud. | A response with This tin can be overridden on a per-backend footing with the |
no-cache | The no-enshroud asking directive is ignored to prevent clients from potentially initiating or forcing revalidation to the origin. | A response with This can be overridden on a per-backend ground with the |
public | N/A | This directive is non required for cacheability, but it is a all-time do to include it for content that should exist buried past proxies. |
individual | N/A | A response with the This can be overridden on a per-backend basis with the |
max-age=SECONDS | The max-historic period request directive is ignored. A cached response is returned equally if this header was not included in the request. | A response with the max-age directive is cached up to the divers SECONDS. |
s-maxage=SECONDS | N/A | A response with the If both Responses with this directive aren't served stale. |
min-fresh=SECONDS | The min-fresh asking directive is ignored. A cached response is returned as if this header was non included in the request. | N/A |
max-stale=SECONDS | The Cloud CDN honors this, and returns a stale cached response only if the staleness of the response is less than the | N/A |
stale-while-revalidate=SECONDS | N/A | A response with This behavior tin can exist enabled for all responses by setting |
stale-if-error=SECONDS | The stale-if-error asking directive is ignored. A cached response is returned as if this header was not included in the asking. | This response header has no effect. |
must-revalidate | N/A | A response with Responses with this directive aren't served dried. |
proxy-revalidate | A response with Responses with this directive aren't served stale. | |
immutable | N/A | No effect. This is passed on to the client in the response. |
no-transform | Due north/A | No transforms are applied past Deject CDN. |
only-if-buried | The merely-if-buried request directive is ignored. A cached response is returned as if this header was not included in the request. | N/A |
Where possible, Cloud CDN endeavors to be RFC-compliant (HTTP RFC 7234), but favors optimizing for cache offload and minimizing the impact that clients tin can have on striking rate and/or overall origin load.
For responses that employ the HTTP/1.1 Expires
header:
- The value of the
Expires
header must be a valid HTTP-date as defined in RFC 7231. - A engagement value in the past, an invalid date, or a value of
0
indicates that the content has already expired and requires revalidation. - If a
Cache-Control
header is present in the response, Cloud CDN ignores theExpires
header.
The presence of a valid, time to come Expires
header in the response lets the response be cached, and does non require other enshroud directives to be specified.
The HTTP/1.0 Pragma
header, if present in a response, is ignored and passed through as-is to the client. Client requests with this header are passed to the origin and exercise non impact how a response is served by Deject CDN.
The Vary
header indicates that the response varies depending on the customer's request headers. In addition to the asking URI, Cloud CDN respects Vary
headers that origin servers include in responses. For example, if a response specifies Vary: Accept
, Cloud CDN uses one enshroud entry for requests that specify Accept: image/webp,image/*,*/*;q=0.viii
and another for requests that specify Accept: */*
.
The table in the Not-cacheable content section lists the Vary
headers that permit content to be cached. Other Vary
header values prevent content from existence cached.
The FORCE_CACHE_ALL
cache manner does not override this behavior. The Vary
headers are of import to avoid cache poisoning betwixt multiple possible origin server responses. Information technology would be unsafe for FORCE_CACHE_ALL
to cause those responses to exist cached.
Vary
headers are sometimes used when serving compressed content. Deject CDN does not compress or decompress responses itself, but it can serve responses that the origin server compressed. If your origin server chooses whether to serve compressed or uncompressed content based on the value of the Accept-Encoding
request header, make certain that the response specifies Vary: Have-Encoding
.
Expiration times and validation requests
A cache entry's expiration time defines how long a cache entry remains valid. The value provided by the s-maxage
(or max-historic period
or expires
) value allows for automated revalidation of stale, user-generated cached content.
When Deject CDN receives a asking, it looks upwards the corresponding cache entry and checks its age. If the cache entry exists and is fresh plenty, the response tin be served from the cache. If the expiration time has passed, Cloud CDN attempts to revalidate the cache entry by contacting one of your backends. This is done before serving the response, unless you enable serve-while-dried, in which case revalidation is performed asynchronously.
For some cache modes, you can ready TTL values. For more information, see Using TTL settings and overrides.
The cache style affects how freshness is determined.
Cache mode | Validation behavior |
---|---|
CACHE_ALL_STATIC | The origin headers (Cache-Control: s-maxage , Cache-Control: max-age , or Expires headers) are consulted to determine freshness. For static content, if origin headers are not nowadays, the configured default_ttl determines freshness. Subsequently the static content is older than default_ttl , Deject CDN revalidates it. |
USE_ORIGIN_HEADERS | Each enshroud entry in a Deject CDN cache has an expiration fourth dimension divers by the Cache-Control: south-maxage , Cache-Control: max-age , or Expires headers in accord with RFC 7234. |
FORCE_CACHE_ALL | Instead of origin headers, the configured default_ttl determines freshness. Afterwards the content is older than default_ttl , Cloud CDN revalidates it. |
If more than than i is nowadays, Cache-Command: s-maxage
takes precedence over Enshroud-Command: max-age
, and Enshroud-Command: max-historic period
takes precedence over Expires
.
Past default, when the expiration time value exceeds 30 days (2,592,000 seconds), Cloud CDN treats the expiration value as if it were 2,592,000 seconds. Downstream clients still see the accurate values of max-historic period
and s-maxage
, even if they exceed 30 days.
Eviction
There is no guarantee that a enshroud entry remains in the enshroud until information technology expires because unpopular entries can exist evicted before they expire at whatsoever time to brand room for new content. As an upper bound, cache entries that aren't accessed for 30 days are automatically evicted.
For more information, run into Eviction and expiration.
Deject CDN can attempt to apply the information in the cached response headers to validate the cache entry with the backend. This happens when both of the following are truthful:
- The previously buried response has a
Final-Modified
orETag
header. - The client request is a
GET
asking that does not containIf-Modified-Since
orIf-None-Match
headers.
Cloud CDN performs this validation slightly differently depending on whether the response was cached by using byte range requests:
- If the response was cached by using byte range requests, Cloud CDN initiates a separate validation request that includes
If-Modified-Since
and/orIf-None-Lucifer
headers. - Otherwise, Cloud CDN adds
If-Modified-Since
and/orIf-None-Match
headers to the client request and forrad the modified request to the backend.
If the buried copy is nevertheless up to engagement, the backend can validate the existing cache entry by sending a 304 Not Modified
response. In this instance, the backend sends only the response headers, not the response trunk. Cloud CDN inserts the new response headers into the cache, updates the expiration time, and serves the new response headers and cached response body to the client.
If the previously cached response does non accept a Last-Modified
or an ETag
header, Cloud CDN ignores the expired enshroud entry and frontwards the client request to the backend unmodified.
Support for byte range requests
A response that satisfies the following criteria indicates that the origin server supports byte range requests:
- Status code:
200 OK
or206 Partial Content
- Header:
Accept-Ranges: bytes
- Header:
Content-Length
and/orContent-Range
- Header:
Final-Modified
and/orETag
with a strong validator
Deject Storage supports byte range requests for most objects. However, Cloud Storage does non support byte range requests for objects with Content-Encoding: gzip
metadata unless the client asking includes an Accept- Encoding: gzip
header. If y'all have Cloud Storage objects larger than 10 MB, make sure that they exercise not have Content-Encoding: gzip
metadata. For information about how to edit object metadata, see Viewing and editing object metadata.
Popular web server software as well supports byte range requests. Consult your web server software'south documentation for details about how to enable support. For more data most byte range requests, see the HTTP specification.
When an origin server supports byte range requests, a Deject CDN cache declines to store an otherwise cacheable response the first time information technology is requested if either of the following is true:
- The response body is incomplete because the customer requested only part of the content.
- The response body is larger than 1 MB (1,048,576 bytes).
When this happens and the response would otherwise satisfy the normal cacheability requirements, the cache records that the origin server supports byte range requests for that cache key and frontward the origin server's response to the customer.
On a cache miss, the enshroud checks whether the origin server is known to support byte range requests. If byte range requests are known to be supported for the enshroud cardinal, the cache does non forrard the client request to the external HTTP(Southward) load balancer. Instead, the enshroud initiates its ain byte range cache fill requests for the missing parts of the content. If your origin server returns the requested byte range in a 206 Fractional Content
response, the cache tin can store that range for futurity requests.
A cache stores a 206 Fractional Content
response only when it is received in response to a byte range request that the enshroud initiated. Because a cache doesn't initiate a byte range request unless it had previously recorded that the origin server supports byte range requests for that enshroud key, a given cache doesn't store content that'southward larger than 1 MB until the second time that content is accessed.
Due to its distributed nature, Deject CDN might sometimes fetch the final chunk from the origin more than once per location. This merely impacts the first few requests per enshroud key.
Request collapsing (coalescing)
Request collapsing (also called coalescing) actively collapses multiple user-driven cache fill requests for the same enshroud primal into a single origin asking per edge node. This tin can actively reduce the load on the origin, and applies to both item requests (responses fetched directly) and chunk requests, where Deject CDN uses Range
requests to fetch larger objects more efficiently.
Asking collapsing is enabled by default.
Complanate requests behave in the following manner:
- Collapsed requests log both the client-facing request and the (complanate) cache fill asking.
- The leader of the collapsed session is used to make the origin fill up asking.
- Request attributes that aren't part of the cache key, such as the
User-Agent
orTake-Encoding
header, only reflect the leader of the collapsed session. - Requests that do non have the same enshroud key cannot be collapsed.
The following diagram shows how requests are coalesced:
In comparison, with asking collapsing disabled or for requests that cannot be coalesced, the number of origin requests and responses can be equal to the number of clients attempting to retrieve an object not currently cached.
For all types of requests, collapsing is enabled by default. For item request types, yous can disable collapsing. Nosotros recommend disabling collapsing for item requests in highly latency sensitive scenarios, such equally ad-serving, where origin load is not a consideration.
The following table summarizes the default behavior and configurability for different request types.
Request type | Default behavior | Configurable | Benefits of collapsing |
---|---|---|---|
Chunk requests | Enabled | No | Can significantly reduce origin bandwidth |
Item requests | Enabled | Yeah | Tin can reduce origin asking volume |
To disable item request collapsing using the Google Cloud CLI for a backend bucket that references a Deject Storage saucepan:
gcloud
Utilize the gcloud compute backend-services
or backend-buckets
control:
gcloud compute backend-services update BACKEND_SERVICE_NAME \ --no-request-coalescing
To enable item request collapsing on a backend bucket using the Google Deject CLI:
gcloud
Use the gcloud compute backend-buckets
command:
gcloud compute backend-buckets update BACKEND_BUCKET_NAME \ --request-coalescing
To enable item request collapsing using the Google Cloud CLI for a backend service, including VM groups and external backends:
gcloud
Employ the gcloud compute backend-services
command:
gcloud compute backend-services update BACKEND_SERVICE_NAME \ --request-coalescing
Requests initiated by Cloud CDN
When your origin server supports byte range requests, Cloud CDN can transport multiple requests to your origin server in reaction to a single client request. Cloud CDN can initiate 2 types of requests: validation requests and byte range requests.
If the response that indicated that your origin server supported byte range requests for a particular enshroud fundamental has expired, Deject CDN initiates a validation asking to confirm that the content hasn't inverse and that your origin server still supports range requests for the content. If your origin server responds with a 304 Not Modified
response, Cloud CDN proceeds to serve the content by using byte ranges. Otherwise, Cloud CDN forwards your origin server'south response to the client. You control expiration times past using the Cache-Control
and Expires
response headers.
On a cache miss, Deject CDN initiates enshroud fill requests for a set of byte ranges that overlap the customer asking. If some ranges of the content requested by the client are present in the enshroud, Cloud CDN serves whatever it can from the cache and sends byte range requests for merely the missing ranges to your origin server.
Each byte range request initiated by Cloud CDN specifies a range that begins at an offset that's a multiple of ii,097,136 bytes. With the possible exception of the final range, each range is as well 2,097,136 bytes. If the content isn't a multiple of that size, the terminal range is smaller. The size and offsets used in byte range requests might change in the future.
As an example, consider a client request for bytes one,000,000 through 3,999,999 of content that is non present in the cache. In this example, Deject CDN could initiate two Go requests, one for the first ii,097,136 bytes of the content and another for the second 2,097,136 bytes. This results in 4,194,272 bytes of enshroud fill up fifty-fifty though the client requested but 3,000,000 bytes.
When you lot utilize a Cloud Storage bucket as your origin, each Go asking is billed as a dissever Form B functioning. You are charged for all GET requests processed by Cloud Storage, including any requests initiated by Cloud CDN. When a response is served entirely from a Cloud CDN enshroud, no Become requests are sent to Cloud Storage, and you are not charged for any Cloud Storage operations.
When Cloud CDN initiates a validation asking or byte range asking, it does not include client-specific headers such every bit Cookie
or User-Agent
.
In the Deject Logging httpRequest.userAgent
field, Cloud-CDN-Google
ways that Cloud CDN initiated the request.
Bypassing the cache
Cache bypass allows requests containing specific request headers to bypass the cache, even if the content was previously cached.
This section provides information about bypassing the cache with HTTP headers, such as Pragma
and Authority
. This feature is useful when yous want to brand certain that your users or customers always have the latest content fetched fresh from the origin server. You might want to practise this for testing, setting up staging directories, or scripts.
If a specified header matches, the cache is bypassed for all cache mode settings, even FORCE_CACHE_ALL
. Cache bypass results in a big number of enshroud misses if the specified headers are common to many requests.
Before you begin
-
Ensure that Deject CDN is enabled; for instructions, encounter Using Cloud CDN.
-
If necessary, update to the latest version of the Google Deject CLI:
gcloud components update
Configuring enshroud bypass
You can specify upward to v HTTP header names. Values are case-insensitive. The header name must be a valid HTTP header field token. A header name must non appear more than once in the list of added headers. For the rules well-nigh valid header names, meet How custom headers work.
Console
- In the Google Cloud console, get to the Load Balancing page.
Go to the Load balancing page
- Click the name of your external HTTP(S) load balancer.
- Click Edit .
- In Backend configuration, select a backend and click Edit .
- Make certain that Enable Deject CDN is selected.
- At the bottom of the window, click Advanced configurations.
- Under Bypass cache on request header, click Add header.
- Blazon a header proper noun, such as
Pragma
orAuthorization
. - Click Update.
- Click Update again.
gcloud
For backend buckets, use the gcloud compute backend-buckets create or gcloud compute backend-buckets update command with the --bypass-enshroud-on-asking-headers
flag.
For backend services, utilise the gcloud compute backend-services create or gcloud compute backend-services update control with the --featherbed-enshroud-on-request-headers
flag.
gcloud compute backend-buckets (create | update) BACKEND_BUCKET_NAME --bypass-cache-on-request-headers=BYPASS_REQUEST_HEADER
gcloud compute backend-services (create | update) BACKEND_SERVICE_NAME --bypass-cache-on-request-headers=BYPASS_REQUEST_HEADER
For example:
gcloud compute backend-services update my-backend-service --bypass-cache-on-request-headers=Pragma --bypass-enshroud-on-request-headers=Say-so
api
For backend buckets, apply the Method: backendBuckets.insert, Method: backendBuckets.update, or Method: backendBuckets.patch API call.
For backend services, utilize the Method: backendServices.insert, Method: backendServices.update, or Method: backendServices.patch API call.
For example:
PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendBuckets
Add the following snippet to the JSON request body:
"cdnPolicy": { "bypassCacheOnRequestHeaders": [ { "headerName": cord } ] }
Disabling cache bypass
What'due south next
- To understand how enshroud modes make information technology easier to cache content, run across Using enshroud modes.
- To enable Cloud CDN for your HTTP(S) load balanced instances and storage buckets, run into Using Cloud CDN.
- To learn near invalidating caches, see Cache invalidation overview.
- To detect GFE points of presence, see Cache locations.
Which Of The Following Devices Can Also Provide Web Caching Services?,
Source: https://cloud.google.com/cdn/docs/caching
Posted by: parksmusere1980.blogspot.com
0 Response to "Which Of The Following Devices Can Also Provide Web Caching Services?"
Post a Comment