WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: WP Super Cache] Cache Causes re-direct to fail (10 posts)

  1. ma2t
    Member
    Posted 6 years ago #

    Hey there,

    I'm using the latest version of wp-super-cache, updated from the 0.6.4 version a few days ago, and I'm noticing some strange behavior.

    I'm using the Permalink Redirect plugin (http://scott.yang.id.au/code/permalink-redirect/) which does a great job at redirecting everything, non-www to www, adds the ending "/" etc.

    But since updating to 0.6.6 I have noticed that if I go to my site without the www, it will redirect as it should. BUT then, if I open a new tab, enter the same url (with out the www again) it does not redirect.

    After looking at the cache folder, as far as I can tell, wp-super-cache is making a cached version of the page when I go to the non www page for the first time, and at this time I get correctly redirected. But the 2nd time I access this url the cached version of the non www is served.

    In the super cached folder im now getting some http://www.mysite.com folders, where before I wasn't.

    SEO and duplicate content is very important to me, so this is a little annoying.

    As a test, I cleared my cache and entered my sites url (without www) into http://www.seologic.com/webmaster-tools/url-redirect.php and it first reports a "HTTP/1.1 301 Moved Permanently", but on the second time, HTTP/1.1 200 OK is reported. Proving this problem.

    I believe it to be a problem with wp-super-cache rather than the re-direct plugin, as it only happen when wp-super-cache is enabled and after a cached page has been created... and since upgrading from 0.6.4.

    Sorry for the long, post, just trying to provide all details I can.

    Below is my .htaccess file.

    ===
    # BEGIN WPSuperCache
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    AddDefaultCharset UTF-8
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{QUERY_STRING} !.*p=.*
    RewriteCond %{QUERY_STRING} !.*attachment_id=.*
    RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*
    RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]

    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{QUERY_STRING} !.*p=.*
    RewriteCond %{QUERY_STRING} !.*attachment_id=.*
    RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*
    RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
    </IfModule>
    # END WPSuperCache

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    Many thanks for your time, and great work on the plugin!
    Cheers,
    Matt

  2. Donncha O Caoimh
    Member
    Posted 6 years ago #

    I'm surprised you didn't see the same "problem" with 0.6.4 but there's no way of caching the headers. You could try turning the cache "half on" but even then I think the header will be 200 and not a redirect.

  3. ma2t
    Member
    Posted 6 years ago #

    Many thanks for your reply donncha. I guess I didn't notice this on the 0.6.4. So it's not possible to not cache the page if it's being redirected.

    I noticed that you redirect www to non-www. But your blog does not fail to redirect on the second load.

    I assume this is due to a .htaccess redirect?. If so, would you recommend this as a solution to this situation. (I used to use this method)

    Thanks a lot.
    Matt

  4. ma2t
    Member
    Posted 6 years ago #

    Hey again,

    I just checked my supercache folder and noticed something a little worrying.

    I see some cached pages from server ip address. I don't want my site to be accessed directly via the ip address. This would also cause issues with duplicate content.

    It redirects correctly when wp-super is disabled.
    Cheers

  5. Donncha O Caoimh
    Member
    Posted 6 years ago #

    Actually, there's something weird going on. I removed my "www." redirect rules from my .htaccess file but it still redirects properly.

    Are you using the latest version of WordPress? Have you set the siteurl to your url without the http://www.?

  6. ma2t
    Member
    Posted 6 years ago #

    Thanks for the reply Donncha.

    I have been running 2.3.3, but I have now upgraded to 2.6.1 to do a thorough test, but the problem still persists.

    In the wp site url field I have http://www.site.com entered (as I want www).

    After I disabled the redirect plugin, wordpress did not redirect away from the server ip address. I assumed this was default wp behavior, but I guess it was the plugin doing the redirect.

    I have been playing around for the last few hours in the new WP, and all redirects correctly with the redirect plugin enabled. But when I enable wp-super-cache in full, it does not redirect (on second page load). But it works fine, and redirects when the cache is set to half on.

    I assume what is happening is:
    1. non www page url entered, and return key pressed.
    2. Page redirected correctly..... AND original url page is cached.
    3. non www page url entered for second time, and return key pressed.
    4. Non redirected page is served from (super)cache.

    It seems like the Super part of the cache is caching the orginal url, and therefore, on second page load causing the old url page to load.

    I don't know if you consider this a problem or not, but it seems to be wp-super-cache which is causing this behavior.

    For now, im running my blog on "half on mode" which seems to work. I'm wondering if a redirect "to-www" in the .htaccess would not cause this behaviour.

    Sorry for the long post, and many thanks for the help.
    Matt

  7. Donncha O Caoimh
    Member
    Posted 6 years ago #

    Does the permalink redirect plugin die() or exit after issuing the header redirect? If it doesn't then yes, wp-super-cache will probably cache the page.
    Or, if it creates a closing </html> tag the the plugin will cache it too.

    Hope that helps!

  8. ma2t
    Member
    Posted 5 years ago #

    Many thanks donncha. Unfortunately I don't know much about how the plugin works.

    For now I will just run it on the "half on" settings. This still works great.

  9. mactac
    Member
    Posted 5 years ago #

    is this fixed? the half-on setting still 302's

  10. Donncha O Caoimh
    Member
    Posted 5 years ago #

    That 302 is generated by WordPress, not by the plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic