A cache is a mechanism to shorten data access times, reduce latency, and improve input/output (I/O) speeds. Adaptive forms cache stores only the HTML content and JSON structure of an adaptive form without saving any pre-filled data. It helps in reducing the time required to render an adaptive form on the client. It is designed specifically for adaptive forms.
Go to AEM web console configuration manager at https://[server]:[port]/system/console/configMgr
.
Click Adaptive Form and Interactive Communication Web Channel Configuration to edit its configuration values.
In the edit configuration values dialog, specify the maximum number of forms, or documents, an instance of the AEM Forms server can cache in the Number of Adaptive Forms field. The default value is 100.
To disable the cache, set the value in the Number of Adaptive Forms field to 0. The cache is reset and all forms and documents are removed from the cache when you disable or change the cache configuration.
Click Save to save the configuration.
Your environment is configured to use cache adaptive forms and related assets.
You can also configure adaptive form caching at Dispatcher for an additional performance boost.
/content/forms/[folder-structure]/[form-name].html
are cached and caching ignores URLs with pattern /content/dam/formsanddocument/[folder-name]/<form-name>/jcr:content
. So, use URLs with extensions to take the benefits of caching.http://host:port/content/forms/af/<afName>.<locale>.html
to request a localized version of an adaptive form instead of http://host:port/content/forms/af/afName.html?afAcceptLang=<locale>
http://host:port/content/forms/af/<adaptivefName>.html
.http://host:port/content/forms/af/<adaptivefName>.html
, and Use Browser Locale in configuration manager is disabled, the non-localized version of the adaptive form is served. The non-localized language is the language used while developing the adaptive form. The locale configured for your browser (browser locale) is not considered and a non-localized version of the adaptive form is served.http://host:port/content/forms/af/<adaptivefName>.html
, and Use Browser Locale in configuration manager is enabled, a localized version of the adaptive form is served, if available. The language of the localized adaptive form is based on the locale configured for your browser (browser locale). It can lead to [caching only the first instance of an adaptive form]. To prevent the issue from happening on your instance, see troubleshooting.To enable and configure caching adaptive forms on Dispatcher, perform the following steps:
Open the following URL for every publish instance of your environment and enable flush agent for publish instances of your environment:
http://[server]:[port]]/etc/replication/agents.publish/flush.html
Add the following to your dispatcher.any file:
/invalidate
{
/0000
{
/glob "*"
/type "deny"
}
/0001
{
# Consider all HTML files stale after an activation.
/glob "*.html"
/type "allow"
}
/0002
{
# Exclude htmls present in AF directories
/glob "/content/forms/**/*.html"
/type "deny"
}
When you add the above:
An adaptive form remains in the cache until an updated version of the form is not published.
When a newer version of a resource referenced in an adaptive form is published, the impacted adaptive forms is automatically invalidated. There are some exceptions to automatic invalidation of referenced resources. For workaround to exceptions, see the troubleshooting section.
Add the below rules dispatcher.any or custom rules file. It excludes the URLs that do not support caching. For example, Interactive Communication.
/0000 {
/glob "*"
/type "allow"
}
## Don't cache csrf login tokens
/0001 {
/glob "/libs/granite/csrf/token.json"
/type "deny"
}
## Don't cache IC - print channel
/0002 {
/glob "/content/forms/**/channels/print.html"
/type "deny"
}
## Don't cache IC - web channel
/0003 {
/glob "/content/forms/**/channels/web.html"
/type "deny"
}
Add the following parameters to the ignore URL parameters list:
/ignoreUrlParams {
/0001 { /glob "*" /type "deny" }
# added for AEM forms specific use cases.
/0003 { /glob "dataRef" /type "allow" }
}
Your AEM environment is configured to cache adaptive forms. It caches all types of adaptive forms. If you require a check of user access permissions for a page before delivering the cached page, see caching secured content.
When you select and add images or videos by way of asset browser to an adaptive form and these images and videos are edited in Assets editor, adaptive forms containing such images are not invalidated from Dispatcher cache automatically.
After publishing the images and video, explicitly unpublish and publish the adaptive forms that reference these assets.
When the adaptive form URL does not have any localization information, and Use Browser Locale in the configuration manager is enabled, a localized version of the adaptive form is served. Only the first instance of the adaptive form is cached and delivered to every subsequent user.
Resolve the issue by performing the following steps:
Open the conf.d/httpd-dispatcher.conf or any other configuration file configured to load at runtime.
Add the following code to your file and save it. It is a sample code modify it to suit your environment.
<VirtualHost *:80>
# Set log level high during development / debugging and then turn it down to whatever is appropriate
LogLevel rewrite:trace6
# Start Rewrite Engine
RewriteEngine On
# Handle actual URL convention (just pass through)
RewriteRule "^/content/forms/af/(.*)[.](.*).html$" "/content/forms/af/$1.$2.html" [PT]
# Handle selector based redirection basded on browser language
# The Rewrite Cond(ition) is looking for the Accept-Lanague header and if found takes the first two character which most likely will be the desired language selector.
RewriteCond %{HTTP:Accept-Language} ^(..).*$ [NC]
RewriteRule "^/content/forms/af/(.*).html$" "/content/forms/af/$1.%1.html" [R]
</VirtualHost>