Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Which configuration must be applied to enable re-fetching of cached items based on Cache Headers sent by AEM

Avatar

Level 7

Which configuration must be applied to enable re-fetching of cached items based on Cache Headers sent by AEM ?

 

 /enableTTL true

 /enableTTL "1"

 

Thanks

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @JakeCham 

 

Please use 

/enableTTL "1"

Ensure the Cache-Control: max-age=60 header. max-age can be any value

- Next set /enableTTL "1"

You will need to restart Apache for this change to take effect:

sudo apachectl restart

 

There is an excellent repository of dispatcher experients. Do check this one https://github.com/adobe/aem-dispatcher-experiments/tree/main/experiments/enableTTL 


Aanchal Sikka

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @JakeCham 
You can use  /enableTTL "1"
try below steps 

/cache {
## The cacheroot must be equal to the document root of the webserver
/docroot "${PUBLISH_DOCROOT}"
## sets the level upto which files named ".stat" will be created in the
## document root of the webserver. when an activation request for some
## handle is received, only files within the same subtree are affected
## by the invalidation.
#/statfileslevel "1"
## caches also authorized data
/allowAuthorized "1"
## Flag indicating whether the dispatcher should serve stale content if
## no remote server is available.
#/serveStaleOnError "0"
## the rules define, which pages should be cached. please note that
## - only GET requests are cached
## - only requests with an extension are cached
## - only requests without query parameters ( ? ) are cached
## - only unauthorized pages are cached unless allowUnauthorized is set to 1
/rules {
$include "/etc/httpd/conf.dispatcher.d/cache/* "
# the invalidate section defines those pages which are 'invalidated' after
# any activation. please note that, the activated page itself and all
# related documents are flushed on an modification. for example: if the
# page /foo/bar is activated, all /foo/bar.* files are removed from the
# cache.
/invalidate {
/0000 {
/glob "*"
/type "deny"
}
/0001 {
/glob "*.html"
/type "allow"
}
/0002 {
/glob "/etc/segmentation.segment.js"
/type "allow"
}
/0003 {
/glob "*/analytics.sitecatalyst.js"
/type "allow"
}

}
/allowedClients {
## By default block all IP from allowing to initiate the invalidation commands
/0000 {
/glob "*.*.*.*"
/type "deny"
}
## Allow certain IP's like publishers to invalidate cache
$include "/etc/httpd/conf.dispatcher.d/cache/ams_publish_invalidate_allowed.any"
}
## The ignoreUrlParams section contains query string parameter names that
## should be ignored when determining whether some request's output can be
## cached or delivered from cache.
## In this example configuration, the "q" parameter will be ignored.
#/ignoreUrlParams {
# /0001 { /glob "*" /type "deny" }
# /0002 { /glob "q" /type "allow" }
#}

## Cache response headers next to a cached file. On the first request to
## an uncached resource, all headers matching one of the values found here
## are stored in a separate file, next to the cache file. On subsequent
## requests to the cached resource, the stored headers are added to the
## response.
## Note, that file globbing characters are not allowed here.
/headers {
"Cache-Control"
"Content-Disposition"
"Content-Type"
"Expires"
"Last-Modified"
"X-Content-Type-Options"
}
## A grace period defines the number of seconds a stale, auto-invalidated
## resource may still be served from the cache after the last activation
## occurring. Auto-invalidated resources are invalidated by any activation,
## when their path matches the /invalidate section above. This setting
## can be used in a setup, where a batch of activations would otherwise
## repeatedly invalidate the entire cache.
#/gracePeriod "2"

## Enable TTL evaluates the response headers from the backend, and if they
## contain a Cache-Control max-age or Expires date, an auxiliary, empty file
## next to the cache file is created, with modification time equal to the
## expiry date. When the cache file is requested past the modification time
## it is automatically re-requested from the backend.
# /enableTTL "1"
}  

 



Avatar

Correct answer by
Community Advisor

Hello @JakeCham 

 

Please use 

/enableTTL "1"

Ensure the Cache-Control: max-age=60 header. max-age can be any value

- Next set /enableTTL "1"

You will need to restart Apache for this change to take effect:

sudo apachectl restart

 

There is an excellent repository of dispatcher experients. Do check this one https://github.com/adobe/aem-dispatcher-experiments/tree/main/experiments/enableTTL 


Aanchal Sikka

Avatar

Community Advisor
use /enableTTL "1" to refetch 
 
# Enable TTL evaluates the response headers from the backend, and if they
# contain a Cache-Control max-age or Expires date, an auxiliary, empty file
# next to the cache file is created, with modification time equal to the
# expiry date. When the cache file is requested past the modification time
# it is automatically re-requested from the backend.
/enableTTL "1"
 
set 
/headers {
"Cache-Control"
} and define max-age so that  After expiring, a browser must refresh its version of the resource by sending another request to a server.
for eg:
 
Cache-Control: max-age=120
It means returned resource is valid for 120 seconds, after which the browser has to request a newer version.