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.

Enable text compression in AEM

Avatar

Level 2

How to enable text compression using OSGi config and dispatcher rules for Json file

12 Replies

Avatar

Community Advisor

Can you elaborate on what type of compression you are referring to?

I guess you are referring to dispatcher compression, if so, you could use the DEFLATE mod, please take a look at these resources that will guide how to enable this:

 

https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/dispatcher-c...
https://www.albinsblog.com/2018/09/improve-performance-of-adobe-experience.html



Esteban Bustamante

Avatar

Community Advisor

Hi,

 

By default, AEM does not compress JSON files. To enable compression for JSON you can add below in dispatcher.any file

/filter{
/0001
{
/glob "*.json"
/type "allow"
/name "Allow JSON"
/action "gzip"
}
}

After making changes to the Dispatcher configuration, restart the Apache web server to apply the new rules.

Avatar

Administrator

@rajesh_didshe Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 2

Hi @kautuk_sahni ,

 

I have tried above both step as @Ravi_Pampana  and @EstebanBustamante mentioned. Tried DEFLATE mod but it's not working and for Filter step getting build failure error on action and name. Have attached Screenshot of build error log for same.

Avatar

Administrator

To enable text compression using OSGi config and dispatcher rules for JSON files in AEM, you can follow these steps:

  1. 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:
    JSON
    {
        "glob": "*.json",
        "type": "allow",
        "name": "Allow JSON",
        "action": "gzip"
    }
    
    • Save the configuration.
  2. Configure the Dispatcher.

    • Edit the dispatcher.any file.
    • Add the following filter rule:
    JSON
    /filter {
        /0001 {
            /glob "*.json"
            /type "allow"
            /name "Allow JSON"
            /action "gzip"
        }
    }
    
    • Save the file.
  3. 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.



Kautuk Sahni

Avatar

Level 2

Hi,

 

Not able to see Dispatcher section in my Cloud Manager, is there any specific permission required for that.

 

Screenshot.png

Avatar

Employee Advisor

in AEM CS the dispatcher configuration resides in GIT.

Avatar

Administrator

To edit your dispatcher configuration in AEM CS, you can either:

  1. Clone the Git repository to your local machine and make your changes there. Then, push your changes back to the repository and deploy them to your Dispatcher instances using Cloud Manager.
  2. Use the Dispatcher configuration UI in Cloud Manager. This UI provides a graphical interface for editing your dispatcher configuration. However, it does not support all of the features that are available in the dispatcher.any file.

If you need to make changes to your dispatcher configuration that are not supported by the Dispatcher configuration UI, you can edit the dispatcher.any file directly.



Kautuk Sahni

Avatar

Administrator

@rajesh_didshe Were you able to succeed? 



Kautuk Sahni

Avatar

Level 1

 @kautuk_sahni 

dispatcher.any file is immutable, So tried above step in filter.any file but getting build error for action.

RajeshDidshe_0-1696674519466.pngRajeshDidshe_1-1696674549311.png