To enable text compression using OSGi config and dispatcher rules for JSON files in AEM, you can follow these steps:
-
Enable text compression in AEM.
- Go to the AEM Configuration Manager.
- Navigate to OSGi > Configurations > Apache Sling Dispatcher.
- Edit the
filter configuration.
- Add the following filter rule:
{
"glob": "*.json",
"type": "allow",
"name": "Allow JSON",
"action": "gzip"
}
-
Configure the Dispatcher.
- Edit the
dispatcher.any file.
- Add the following filter rule:
/filter {
/0001 {
/glob "*.json"
/type "allow"
/name "Allow JSON"
/action "gzip"
}
}
-
Restart the Dispatcher.
Once you have completed these steps, text compression will be enabled for JSON files in AEM.
Note: If you are using AEM as a Cloud Service, you cannot edit the dispatcher.any file directly. Instead, you must use the Dispatcher configuration UI. To do this, go to the Dispatcher section of the Cloud Manager and click Edit Configuration. Then, add the filter rule.