Following up on an issue that affected a friend of mine, also noted at http://drupal.org/node/143643
Essentially, with 'normal' caching mode enabled, IE6 users were getting a blank page on the second load of an arbitrary URL.
The problem seems to be in drupal_cache_header, and exists in Drupal 5 and 6.
(http://api.drupal.org/api/function/drupal_page_cache_header)
Below you'll see the header dumps for IE6 and Firefox that helped me figure this out.
As you can see, IE6 appends a "; length=..." entity to the If-Modified-Since request header. Additionally, IE6 does not respect the use of ETags.
The first is trivial to fix with a regex. The second, since the ETags you seem to use are a basic md5 of the last modified date (i.e., basically redundant), is just as simple to compensate for.
The patches below are marked with // *** description
function drupal_page_cache_header($cache) {
// Set default values:
$last_modified = gmdate('D, d M Y H:i:s', $cache->created) .' GMT';
$etag = '"'.md5($last_modified).'"';
// See if the client has provided the required HTTP headers:
// *** Added preg_replace; some browsers append a "; length=..." entity to the header
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? preg_replace('/;.*$/','',stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE'])) : FALSE;
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
// *** Added:
// ***IE6 does not support Entity Tags, so depend on the if_modified_since to guide us.
if (preg_match('/MSIE\s6\.\d+/i',$_SERVER['HTTP_USER_AGENT']) && $if_modified_since!==false)
$if_none_match = '"'.md5($if_modified_since).'"';
if ($if_modified_since && $if_none_match
&& $if_none_match == $etag // etag must match
&& $if_modified_since == $last_modified) { // if-modified-since must match
header('HTTP/1.1 304 Not Modified');
// All 304 responses must send an etag if the 200 response for the same object contained an etag
header("Etag: $etag");
exit();
}
// Send appropriate response:
header("Last-Modified: $last_modified");
header("ETag: $etag");
// The following headers force validation of cache:
header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Cache-Control: must-revalidate");
// Determine if the browser accepts gzipped data.
if (@strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE && function_exists('gzencode')) {
// Strip the gzip header and run uncompress.
$cache->data = gzinflate(substr(substr($cache->data, 10), 0, -8));
}
elseif (function_exists('gzencode')) {
header('Content-Encoding: gzip');
}
// Send the original request's headers. We send them one after
// another so PHP's header() function can deal with duplicate
// headers.
$headers = explode("\n", $cache->headers);
foreach ($headers as $header) {
header($header);
}
print $cache->data;
}
Header dumps:
Mozilla (first try):
GET http://localhost/work HTTP/1.1
Accept-Language: en-us,en;q=0.5
Pragma: no-cache
Cache-Control: no-cache
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Host: localhost
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
Cookie: SESS26bb99f0cadcebe187fddf01aa93ab47=v145pl62tngok2f9ighres4683; __utma=175679715.93649940.1204101961.1204101961.1204101961.1; __utmb=175679715.23; __utmc=175679715.23; __utmz=175679715.1204101961.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Keep-Alive: 300
Proxy-Connection: keep-alive
Referer: http://localhost/HTTP/1.1 200 OK
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: must-revalidate
ETag: "a002a6eb6ee5781b00740ad47387d932"
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Connection: close
Date: Wed, 27 Feb 2008 02:15:41 GMT
Server: Apache
Last-Modified: Wed, 27 Feb 2008 02:10:44 GMT
Mozilla (second try):
GET http://localhost/work HTTP/1.1
Accept-Language: en-us,en;q=0.5
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Host: localhost
Accept-Encoding: gzip,deflate
If-None-Match: "a002a6eb6ee5781b00740ad47387d932"
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
Cookie: SESS26bb99f0cadcebe187fddf01aa93ab47=v145pl62tngok2f9ighres4683; __utma=175679715.93649940.1204101961.1204101961.1204101961.1; __utmb=175679715.24; __utmc=175679715.24; __utmz=175679715.1204101961.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Keep-Alive: 300
Proxy-Connection: keep-alive
Referer: http://localhost/work
If-Modified-Since: Wed, 27 Feb 2008 02:10:44 GMTHTTP/1.1 304
Etag: "a002a6eb6ee5781b00740ad47387d932"
Content-Type: text/html
Connection: close
Date: Wed, 27 Feb 2008 02:16:18 GMT
Server: Apache
IE6 (first try):
GET http://localhost/work HTTP/1.0
Accept-Language: en-us
Pragma: no-cache
Accept: */*
Host: localhost
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Cookie: SESS26bb99f0cadcebe187fddf01aa93ab47=kdnsbghc61kau5o525hos0vcl6
Proxy-Connection: Keep-Alive
Referer: http://localhost/HTTP/1.1 200 OK
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: must-revalidate
ETag: "a002a6eb6ee5781b00740ad47387d932"
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Connection: close
Date: Wed, 27 Feb 2008 02:12:21 GMT
Server: Apache
Last-Modified: Wed, 27 Feb 2008 02:10:44 GMT
IE6 (second try):
GET http://localhost/work HTTP/1.0
Accept-Language: en-us
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
Host: localhost
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Cookie: SESS26bb99f0cadcebe187fddf01aa93ab47=kdnsbghc61kau5o525hos0vcl6
Proxy-Connection: Keep-Alive
Referer: http://localhost/work
If-Modified-Since: Wed, 27 Feb 2008 02:10:44 GMT; length=18016HTTP/1.1 500 Internal Server Error
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: must-revalidate
ETag: "a002a6eb6ee5781b00740ad47387d932"
Content-Type: text/html; charset=iso-8859-1
Content-Encoding: gzip
Connection: close
Date: Wed, 27 Feb 2008 02:13:00 GMT
Server: Apache
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | ie6_cache.patch | 1.21 KB | redndahead |
| #14 | ie6_no_gzip.patch | 1.23 KB | bcn |
Comments
Comment #1
fiLi commentedI had this same problem, and your patch worked for me. I'll let it run for a while to make sure, but it looks good.
Thanks for posting this.
Comment #2
Joe_41170 commentedI had the same problem. I've been beating my head against the wall for three days over this because without the normal catching mode enabled my website was slow as a turtle.
Your patch seems to work great, no problems now. Thank you very much!
Comment #3
CompShack commentedI'm having the same problem when enabling Caching mode. What file is this function (drupal_page_cache_header) from?
Thanks for your help.
Edit: I found the file - I will test and report back!
Comment #4
CompShack commentedAlready, now I can turn Cache mode on and no problems in IE6 :) - I was getting a white blank page when guests visit the site. Guests would see the pages fine for the 1st visit but then when things gets cached, visitors will see white pages all over the place!
Thanks for the fix - so far works great. Site runs a lot faster. I Will report back if I notice any side effects.
Comment #5
drummNo patch file is attached. Please see http://drupal.org/patch/create.
This should be fixed in the current development version, where there are more active reviewers, first.
Comment #6
dcoun commentedI confirm this problem but it is not solved with the above patch.
It happens in every page when refreshing.
IE 6.0.2900.2180
Comment #7
dcoun commentedI have tested it more. It does work when a user has logged on, not for the visitors.
Comment #8
dcoun commentedAfter patching the first post's changes. Just to describe it better:
Initial request (headers):
Initial response (header)
Request during first reload-refresh (headers)
Response during first reload-refresh (headers)
The webpage's source is included in the second response but IE shows a white page with the following as page source:
Request during second or more reload-refresh (headers)
Response during second or more reload-refresh (headers)
The white empty page is still here in IE6
Comment #9
dcoun commentedIf you make a clean cache data, IE6 loads the page during refresh and replaces the white page with the actual webpage, but in the next refresh, the white page comes again.
Please help, drupal cache is useless with this bug.
Comment #10
dcoun commentedFinally it was solved after disabling module clickpath. I do not know why, but now it works.
Comment #11
XakepaBG commentedHello everybody,
It seems to me the bug only appears when the IE6 has a bug in the combination of reporting gzip support, but failing to do it properly.
This happens to IE6 before the SP2 update of WinXP, I think.
So, if you excuse me, try forgetting about the patch up there, and only (in bootstrap.inc) replace this:
with this:
and your visitors with IE6 featuring the faulty gzip support should be served plain pages instead of gzipped pages
I hope this helps any of you
:-)
Comment #12
johnalbinA real patch would be nice. :-) http://drupal.org/patch/create
Comment #13
lias commentedsubscribing
Comment #14
bcn commentedThis is basically just the changes described in #11. Not sure if this is the right approach, or even if it works... I just rolled the patch.
Comment #15
wpanssi commentedI followed instructions on #11. With IE 6 page caching seems to wlrk, no white screens BUT with IE 7 I get:
Does someone know how to get this working - without side effects??
Tnks in advance!
Comment #16
wpanssi commentedOk, I think it's #11 that just doesn't work. With the original patch presented in the first post it seems to work, so far..
Comment #17
redndahead commentedHere is an updated version of the patch. declared $damn_ie6 var to fix issue in #15. Also renamed $damn_ie6 to $is_ie6. Watch your language ;) Plus it reads better. Combined two if statements. Not tested as I don't have IE6
Comment #18
XakepaBG commentedHi all,
haha, watch the language, lol :-) sure
Of course it'll fail, #15/16 - you have your Error Reporting in your PHP set to cry and moan about EVERY little pseudo-issue - such as having a variable not defined prior to an assignment operation(something PHP happily forgives altogether). Then the error message sends text to the browser, and some subsequent header redirect doesn't work :-)
For development - most people have Notices disabled
For production - most people have all error reporting disabled
play with PHP's manual and error_reporting() and co :-)
Nice save, #17, when I initially found the solution I rushed to post it here and save some suicidal lives :-)
well done to you, optimizing the code for generations to use :-)
Comment #19
cburschkaDrupal core is required not to print notices regardless of what level error reporting is set to, mainly because most developers have it on and would very much prefer their test site not being broken. Also, "pseudo-issue" is kind of subjective; reading an unset variable is definitely sloppy coding. ;)
Edit: I cannot test this patch. I have IE 6, but post-SP2, and the issue does not exist for me.
Comment #20
ezra-g commentedCan someone post instructions for reliably recreating this issue with IE6 and fresh Drupal install? Also the Microsoft support page for this issue appears to be http://support.microsoft.com/default.aspx?scid=kb;en-us;823386&Product=i....
Comment #21
CompShack commentedWhy can't we get this fixed in D6?!! I upgraded my site from D5.7 to D6.4 and the problem remained. I was having the same problem in D5. over 60% of my site visitors still use IE6, it sucks but there is nothing i can do about it. I've tested this with ie6 version version: 6.0.2900.2180.xpsp_sp2_gdr
I will have to re-apply the fix and report back.
Comment #22
redndahead commentedIt definitely won't get fixed unless it goes RTBC. So if it works for you please post instructions to test and change the status to RTBC.
Comment #23
millions commentedsubscribe
Comment #24
millions commentedI'm getting this error when I go to admin/build/modules after applying the patch:
Parse error: syntax error, unexpected $end in bootstrap.inc on line 998
Comment #25
millions commentedLooks like I was missing an end bracket. thanks.
Comment #26
millions commentedThis seems to have worked to fix IE6, but now I'm having this problem: http://drupal.org/node/121820 where in Opera and Firefox the home page shows as gibberish. Disabling caching fixes that problem as well. Is there a patch that makes caching work in IE6 AND Opera/Firefox?
Comment #27
redndahead commentedI think that's a confirmation from xoso for the patch working. Setting to RTBC
Opera and FF issues should be worked out in the other issue queue.
Comment #28
johnalbinActually, if Xoso applied the patch but had a missing end bracket (in #24 & #25). that's not a confirmation that the patch works.
Also, its sounds like the patch caused the Opera/Firefox issues. But perhaps I'm misreading.
Wish I could help with this issue, but I can't reproduce.
Comment #29
millions commentedSomething in my settings with the patch caused the Opera/Firefox issue. It sounds like it has to do with the gzip, but I don't know enough about coding to try to fix it. I have caching disabled at the moment...
Comment #30
redndahead commentedI'm pretty sure the missing end bracket was his mistake when applying the patch. There are no missing brackets in the patch. I just tested to see if this patch messes with opera/firefox and the code does not affect these browsers. Setting it back to RTBC.
Comment #31
millions commentedSomething in the patch, I believe combined with apache, is causing the opera/firefox issue. All I know is without this patch opera/firefox work and ie6 doesn't, and with it it's reversed. With the caching disabled they all work.
Comment #32
dries commentedPersonally, I'm not a big fan of browser specific hacks.
Comment #33
redndahead commentedDries,
Understandable but since this causes a white screen we either need to document that it is a known issue in IE6 or patch it. If you would like to document it just tell me where and I'll take care of it.
Comment #34
millions commentedIt would be great if someone can help me figure out why this is causing the gibberish rendered page in Firefox with caching enabled. It only happens for anonymous users.
So to sum up:
With Caching enabled 1 of two things occurs:
1)No IE6 patch means FF works fine, IE6 displays a blank page on 2nd load or refresh for anonymous users.
2)With IE6 patch means FF displays gibberish on 2nd load or refresh for anonymous users.
With Caching disabled both work fine, although slower.
I don't believe my issue has to do with my post in #26 because I don't believe I have zlib and I don't have that problem without applying this ie6 workaround.
Comment #35
millions commentedI am running XML Sitemap 1.6 (unrelated to this problem) which I believe does require zlib so maybe I do have it.
I tried adding php_flag zlib.output_compression off (or on) to my .htaccess file in both with and without the IE6 patch and it just created 500 Internal Server Errors and my site would not load.
Comment #36
johnalbinYou don't need to change the status of the issue to get help with this patch. If the patch breaks Firefox, the patch needs to be improved.
Comment #37
millions commentedsorry about that, just trying to find some answers!
I also tried my sites/default/settings.php file with ini_set('zlib.output_compression', 'Off') and that didn't work either.
I'm on Godaddy, I have access to my php.ini file on the site, but running phpinfo says that the loaded file is php5.ini which is not in my root directory...
Comment #38
millions commentedComment #39
redndahead commentedXoso,
I really don't know what your issue is, but put a drupal_set_message('Not using gzip') after
and you should see that the message never gets displayed in FF or Opera. So I'm not sure how this patch can affect FF or Opera.
Comment #40
millions commentedThanks for the help, can you tell me exactly what/where I should paste please so I can try it out?
Comment #41
redndahead commentedIf you look at the last bit of the patch you will see this:
After you patch your database.inc file look for that section and change it to this:
Comment #42
millions commentedThanks, I tried that and still get the binary results with caching enabled in FF. This is supposed to be in the bootstrap.inc right? not the database.inc?
Thanks for your help
Comment #43
redndahead commentedYes sorry my brain was thinking about another patch at the same time. Can you create a test installation of drupal on your server with the default settings, apply the patch and see if you still have the issue?
Comment #44
millions commentedJust an update... I had read here (http://drupal.org/node/143641#comment-948227) that this may be host dependent. I was on godaddy and switched to another host today. I enabled caching, and checked IE6 and saw that it was working so I was ecstatic. Later I realized I still had the patched version of bootstrap.inc running and it was causing the gibberish or double compression in Firefox still.
I reverted to the original bootstrap.inc (removed the earlier patch in #17), and now Firefox is working as I expected it would, but the IE6 problem has been fixed as well.
Could it be that the IE6 blank screen is really just host dependent somehow?
Also, this means that somewhere there is a setting (on both hosts) that conflicts with the patch posted above, but I don't know enough to try to find out what it is.
Comment #45
PixelClever commentedThis is showing up for me also on Drupal 6.6. I don't think it is a server configuration issue, I could be wrong though.
Disabling the page compression takes care of the issue for me. Not an ideal solution, but at least the site doesn't look like it's down for IE users.
Comment #46
senyahnoj commentedlooks like a problem with apache mod_deflate (gzip) and ie6:
http://support.microsoft.com/kb/321722
you can set the expires header to be -1 and this fixes the problem:
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') !== false)
{
header('Cache-Control: no-cache');
header('Expires: -1');
}
http://uk3.php.net/manual/en/function.header.php#88875
http://support.microsoft.com/kb/234067/en-us
Comment #47
PixelClever commentedRemoving (pre SP2) from title as this happens on post sp2 versions as well.
Comment #48
catchIE6 != critical.
Comment #49
Lucasljj commentedDrupal 7 require Internet Explorer 8.x and later, see https://www.drupal.org/node/61509
Comment #50
David_Rothstein commentedThat page was misleading (and looks like it since has been fixed). We haven't officially dropped support for IE6 in Drupal 7. Certainly these issues are very low priority now, but if someone wants to fix them and can do it in a way that doesn't hurt other browsers, it's still possible to do so.