I'm not sure if this is a Redirect (http://drupal.org/project/redirect), or Boost problem - but I've just discovered that if I have a redirect which is highlighted by 'Redirect' as yellow and says that "this redirect overwrites and existing path' - then the redirect works the first time (A 301 moved permanently response). But a second visit to the redirected url returns HTTP/200 and shows a blank page that Boost is holding in its page cache - so no redirect occurs. :-(
For redirects that are not in the site's existing path - everything works fine.
Thoughts?
Here's the response header for a request to page http://www.58bits.com/photos/a-short-trip-to-savannakhet-laos which should be redirected, and which works fine for the first request (HTTP/301)
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Content-Encoding: gzip
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0,private
Last-Modified: Sun, 31 Mar 2013 20:27:07 +0000
Keep-Alive: timeout=15, max=100
ETag: "1364761627"
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Date: Sun, 31 Mar 2013 20:27:07 GMT
Transfer-Encoding: chunked
Connection: close
X-Powered-By: PHP/5.3.10-1ubuntu3.6
X-Redirect-Id: 16
Content-Type: text/html
Location: http://www.58bits.com/photos/photos-of-savannakhet-laos
And here are the response headers for the second request (HTTP/200) - which is not redirected.
Server: Apache/2.2.22 (Ubuntu)
Content-Encoding: gzip
Vary: Accept-Encoding
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
ETag: "63-4d93e53fafcc0;4d925a50db940"
Keep-Alive: timeout=15, max=100
Content-Length: 100
Expires: Sun, 19 Nov 1978 05:00:00 GMT
X-Cached-By: Boost
Date: Sun, 31 Mar 2013 20:32:45 GMT
Accept-Ranges: bytes
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Comment | File | Size | Author |
---|---|---|---|
#32 | boost_redirect-1957532-31-D6.patch | 797 bytes | jwilson3 |
#25 | boost_redirect-1957532-25.patch | 528 bytes | azinck |
#25 | interdiff.txt | 1.02 KB | azinck |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedBoost has been known to cache with a redirect module before, the redirect module should exit immediately after having sent the 302 header instead of getting to the boost hook on page output/ exit.
RewriteCond %{ENV:REDIRECT_STATUS} 200
should also skip boost in .htaccess but doesn't (sometimes), boost is known to work with url aliases/ global redirect/ fast404 e.g. other modules that output headers so really it's redirects problem. It may be temporarily solved by adding
RewriteCond %{ENV:REDIRECT_STATUS} 302 OR
above the 200 line in .htaccess and removing the cached file, which might (assuming that an internal redirect is set by the redirect module) skip all the boost rewrite rules and never present the blank page so it should go to index.php and drupal should work as normal but that's basically a guess because it's quite likely that boost is still going to generate that blank page until the redirect module is fixed.
Comment #2
anthony.bouch CreditAttribution: anthony.bouch commentedThanks Philip - that helps.
Best,
Tony
Comment #3
dadderley CreditAttribution: dadderley commentedI have the same problem on 2 sites.
In both cases I had to disable Boost.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedDoes the older module Global Redirect work ? (it used to), it's a redirect problem otherwise as explained before. You can get around this by writing a rewrite rule.
Comment #5
apemantus CreditAttribution: apemantus commentedReferenced here: #1957530: Redirect and Boost?
I'm having this problem as well; initially I thought it should be a Redirect issue, but now I'm not so sure. Redirect exits by calling drupal_exit, which seems correct, but which then triggers boost_exit.
However, redirect has set the header status to 301. So once $_boost['header_info'] = boost_get_header_info(); is called, can boost_exit then ignore all pages where $_boost['header_info']['status'] matches 301/302?
Comment #6
apemantus CreditAttribution: apemantus commentedComment #7
furamag CreditAttribution: furamag commentedI think apemantus is right. Boost should not create cache file if redirect status code set to 301 or 302. We don't need to cache redirect pages. I added following code to boost_exit function:
I added my code after following code:
Please test it and let me know if it works for you. If it works I will create patch then.
Comment #8
Dave ReidIf I'm not mistaken, shouldn't boost not apply if the $destination parameter passed to boot_exit() is not empty? Wouldn't that cover all redirect cases? Is there a valid reason we'd want Boost to cache any redirects of any kind?
Comment #9
chymz CreditAttribution: chymz commentedI tried #7 but not working I think...
I can give my little workaround, in boost.module, line 307 (on DEV version)
I replace this :
By this :
Hope this help...
Here is the original idea : https://drupal.org/node/1176534
Comment #10
azinck CreditAttribution: azinck commentedI agree with Dave Reid in #8. The Boost module previously attempted to solve this problem in boost_drupal_goto_alter() but the redirect module doesn't call drupal_goto(). I don't see any reason not to move that logic into boost_exit(). Patch attached.
Comment #11
azinck CreditAttribution: azinck commentedPrevious patch had some whitespace cruft.
Comment #12
joelstein CreditAttribution: joelstein commentedWorks for me!
Comment #13
apemantus CreditAttribution: apemantus commentedYep - works for me to - this has been a bit of a pain this issue, as previously had to whitelist a ton of redirects. Thanks!
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedThis patch hasn't been applied to Version 7.x-1.0 yet - only Beta 2 as it seems. The problem still exists in the current stable version.
Comment #15
swim CreditAttribution: swim commentedNot sure what @14 is talking about :S.
Applies fine for me on both stable (1.0) & dev (1.x). Without the patch applied users requesting pages which redirect can be served up a blank page. This should hopefully be low hanging fruit for maintainers, patch works a treat.
Comment #16
Vacilando CreditAttribution: Vacilando commentedWorks perfectly for a long time on several sites; please apply to the dev version at least.
Comment #17
Vacilando CreditAttribution: Vacilando commentedCould the maintainers please commit this to DEV? (One patch less to have to keep applying on multiple sites.)
Comment #18
bendev CreditAttribution: bendev commentedThis is working for my site as well.
Would appreciate to commit this...
Comment #19
makimaki CreditAttribution: makimaki commentedIf I wanted to apply this speicifc patch to my stable version 7.x-1.0 inmy production site how would I go about doing this?
I am fairly new to drupal patches but I have some programming know how (just enough to be dangerous) I need this for my site and don't want to wait for SEO ressons when it's offically released.
As I currently understand this, I need to go to the boost module folder, find the file named boost.module and make some changes. If I am on the right path, what do I need to replace?
Any help appreciated.
Comment #20
aufumy CreditAttribution: aufumy commentedMakimaki
You can manually apply the patch by removing the lines that start with the minus sign: -
and adding the lines that start with the plus sign: +
in the order that the patch files shows
e.g. for the patch file https://www.drupal.org/files/issues/boost_redirect-1957532-11.patch, edit the boost.module and remove the entire function boost_drupal_goto_alter(), and add an if statement inside the function boost_exit()
More information: https://www.drupal.org/patch/apply
Comment #21
makimaki CreditAttribution: makimaki commentedThank you. Thank you, aufumy. You are an angel. It works and I learned something new. It's not so difficult after all. Thanks once again.
Comment #22
akosipax CreditAttribution: akosipax commentedPatch applies cleanly on 7.x-1.0 and it fixes the problem.
Comment #23
joelstein CreditAttribution: joelstein commentedI think we need to leave the implementation of hook_drupal_goto_alter(). Even though Redirect doesn't use drupal_goto(), lots of modules do, including core Search (see search_view() which uses drupal_goto() when visiting /search). See #1176534: Bypass caching on redirects.
Comment #24
pipicom CreditAttribution: pipicom commentedHad exactly the same problem. #11 solved it.
Thank you azinck.
Comment #25
azinck CreditAttribution: azinck commented@joelstein. Good point. Patch updated to retain boost_drupal_goto_alter()
Comment #26
robertstaddon CreditAttribution: robertstaddon commentedApplying the patch from @azinck in #25 worked for me. Thanks!
Comment #27
RAWDESK CreditAttribution: RAWDESK commented#25 fixed it for me too.
Comment #28
OWast#25 solved the problem and is rolling without problems in production environment.
Comment #30
bgm CreditAttribution: bgm commentedCommited to 7.x-1.x.
Thanks! (and sorry it took so long
Comment #32
jwilson3I've rerolled the patch in #25 for a Drupal 6 site.