Expand my Community achievements bar.

SOLVED

Dispatcher No Cache and Internet Explorer Error

Avatar

Level 3

Hi all,

I am using this line of code: <% response.setHeader("Dispatcher", "no-cache"); %> to prevent caching of some pages on my CQ site. This works very well in Chrome but actually causes a 500 Internal Server Error when using IE. Interestingly, even when setting the standard HTTP no-cache headers (below) we see the same behaviour:

<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0); // Proxies.
%>

Furthermore, even when setting these headers as meta tags, we see the same server response when hitting the page from IE. Please note that we do not see the problem when accessing the site on the Author instance, only the Publisher. Any thoughts as to what I'm doing wrong will be very much appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10
7 Replies

Avatar

Employee

The server generates a 500 error? Like you see it in the AEM access.log file?

Avatar

Level 3

Yeah, weird right?

Here's a screen shot of the server's reaction...[img]Screen Shot 2014-09-12 at 19.07.56.png[/img]

Avatar

Employee

That's from Apache (I think). Does this also happen if you hit AEM directly (from IE)?

Avatar

Level 3

Just to add some more context, I have now discovered that the above conflicts with some cookie-based code immediately after it:

<%
  response.setHeader("Dispatcher", "no-cache");
%>


<%

// Check for the existence and value of the log-in cookie
Cookie[] cookies = request.getCookies();

// Boolean to use throughout the comp
Boolean REDACTED1 = false;

// Loop over the available cookies and search for the required one

for(Cookie cookie : cookies){
    // Check the match
    if(null != cookie && cookie.getName().equals("REDACTED") && cookie.getValue().equals("REDACTED")){
    REDACTED1 = true;
    }
}

%>

If I remove the code inside the for loop, it works. Interestingly, ANY code added inside the for loop causes the breakage.

Avatar

Correct answer by
Level 10

Avatar

Level 3

Yes, Sham, thanks. It is whitelisted. The problem is specific to IE (all versions) not Chrome or Safari.

Avatar

Level 10

courtthreeGDC wrote...

Yes, Sham, thanks. It is whitelisted. The problem is specific to IE (all versions) not Chrome or Safari.

 


Which version of IE? Does it happen with geometrixx site also?