Expand my Community achievements bar.

Publish Instance Not Returning Last-Modified HTTP Response Header

Avatar

Level 4

I'm trying to get our AEM 6.3 publish instances to return the HTTP Last-Modified header, it currently only returns:

- Date: Thu, 21 Nov 2019 19:27:58 GMT

- X-Content-Type-Options: nosniff

- X-Frame-Options: SAMEORIGIN

- Content-Type: text/html; charset=UTF-8

- Transfer-Encoding: chunked

I tested dispatcher caching of headers which seemed to work, but of course the Last-Modified header is missing, because it's not present on the publish instances.

We're using: dispatcher-apache2.2-4.2.3

I'm wondering, how would I do this?

It seems I'll need to insert some code in a high level element, maybe global, or the header -- that prints the Last-Modified header with the page's last modified time as the value?

It would be great if a link to a how-to were included in the dispatcher doc as without this header, all of the content appears rather new, even if it may not be. This can affect search engine results.

It would also be nice if Last-Modified were one of the default headers present on publish instance pages.

Is there some recommended default component or file to do this in, where the existing headers might also get set? It might be nice to be able to add these via a configMgr setting.

I saw these two posts:

https://forums.adobe.com/thread/2365958

https://aemcorner.com/aem-avoid-page-caching-through-request-headers/

but am not sure how to go about it.

Maybe something like this:

<%

response.setHeader("Last-Modified", "${'dd-MM-yyyy HH:mm' @ format=properties['jcr:lastModified'], timezone='GMT+05:30'}");

%>

I'm not sure where to add it, or even if the above code would work, or is the correct approach.

Thanks for any help!

0 Replies