Movatterモバイル変換


[0]ホーム

URL:


  1. Home
  2. Reference documentation
  3. VCL reference
  4. Subroutines

vcl_hit

The built-invcl_hit subroutine is executed when an object has been found in the cache and is available to be delivered to the client.

A hit in cache usually, but not always, means that the object isfresh; that is, it is within the TTL set by the origin or within thevcl_fetch subroutine. In cases where the object is stale, but is configured with a positiveberesp.stale_while_revalidate time that has yet to expire, this will still be considered a hit and will trigger a background fetch to repopulate the cache asynchronously. A stale object may also trigger ahit if the backend is consideredsick; that is, it has a health check configured, the health check is consistently failing, and the object is configured with aberesp.stale_if_error time which has not expired.

Thehit subroutine shouldreturn(deliver) to deliver the object. It is also possible toreturn(pass), ignoring the hit and instructing Fastly to fetch from the backend anyway. The exception statementsrestart anderror may both be used invcl_hit.

Typicallyhit is executed on afetch node as a result ofclustering.

State transitions

  • hashreturn(hash)
vcl_hit

To see this subroutine in the context of the full VCL flow, seeour guide about Fastly VCL.

Tokens available in this subroutine

The following limited-scope VCL functions and variables are available for use in this subroutine (those inbold are availableonly in this subroutine, those available in *all* subroutines are not listed):


[8]ページ先頭

©2009-2025 Movatter.jp