Expand my Community achievements bar.

SOLVED

AEM: Custom override for Off-time (OOTB) expired pages

Avatar

Level 2

Hope all are doing great! Actually, reaching out here to get some clarification on one AEM Out of the Box feature.

 

  • At present, if any page is marked with a past time asOff time” or future time as “On time” , then the Sling resolution dispatches 404 response state while resolving the request. I am looking for some information on when exactly the response state gets into “committed” state ? i.e. any further updates on response thereafter would result in an illegalStateException.
  • With this Out of the Box feature that AEM provides currently, I'm seeing some intermittent behavior where with random service rankings, the filter chaining is getting prioritized differently. Any idea would be helpful to know what approximate service ranking be good to chain my custom sling filter before the 404 status commitment.I’m trying to override the existing feature by injecting my filer chain at prior and redirect (301) the expired pages into some dedicated paths for certain needs (retain SEO value etc.). But intermittently the override is failing and my custom filter is chained after the 404 committed state.
  • Note:  I'm using Request scope filter with specific request patterns.  Also, to make sure response state gets immediately commited via my custom filter, I'm flushing the buffer so that further any state change does not occur. But, still the OOTB 404 state only is getting effective.

DJSarkar_0-1713373000423.png

 

Would be great to hear back !

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hey DJ Sarkar!

 

Using custom filter's for redirects may create some confusion down the line.

 

Why not modify the OOTB /libs/sling/servlet/errorhandler/404.jsp, in code call your service to verify if this path needs to be 301 or 404. Depending on the outcode either redirect page or serve a 404.

 

This way it will always get triggered and allow you to redirect any page where needed.

 

Regards,

Peter

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Hey DJ Sarkar!

 

Using custom filter's for redirects may create some confusion down the line.

 

Why not modify the OOTB /libs/sling/servlet/errorhandler/404.jsp, in code call your service to verify if this path needs to be 301 or 404. Depending on the outcode either redirect page or serve a 404.

 

This way it will always get triggered and allow you to redirect any page where needed.

 

Regards,

Peter

Avatar

Community Advisor

Hello @DJSarkar ,

The solution described in the original post calls for maintaining a list/record of pages that could grow over time and the overhead of keeping that list in sync across AEM publish instances. In the event of failure of an existing  AEM publisher instance or an additional new AEM publisher instance in the cluster, I can imagine a file in GIT repository to be deployed to that instance.

To maintain HTTP 301 and HTTP 302 page responses for known list of pages, there are the few out of the box/alternate features that could be leveraged,

1. Use the 302 redirect field from the page properties called "Redirect" (property name:"cq:redirectTarget").

2. (AEM On-premises only) Use the ACS Commons provided Map Manager to keep a list of redirects. One dedicated page for HTTP 301 and another for HTTP 302.

3. Leverage CDN to maintain the list of urls and their redirects.

4. Dispatcher Web server configurations.

 

These methods would also prevent calls to AEM Publishers which eventually would be a HTTP 301 or HTTP 302.

 

thanks,

Preetpal

Avatar

Administrator

@DJSarkar 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,

 

The suggestion provided by Peter was covering most of the use scenarios while some of them could not due to earlier buffer state being flushed. But that worked out for happy paths! hence marked that as correct approach. Thanks !

Avatar

Administrator

@DJSarkar I hope you found the AEM community helpful. We look forward to your return as either a learner or a mentor. The community flourishes with SMEs like you. Please encourage your AEM peers to contribute as well. Happy AEM learning!



Kautuk Sahni