Support » Plugin: WP Super Cache » [Plugin: WP Super Cache] Plugin is caching files outside of my blog

  • Resolved NerdWallet


    I have a site at with its own non-WP site files. Within the site I maintain a WP blog at the subdirectory /blog/.

    I installed Super Cache and everything is working perfectly fine, the only problem is that it is also caching files outside of the /blog/ subdirectory. So not only is it caching all of my blog files, it is caching my standard site files as well, which I don’t want (for example,

    I’ve checked .htaccess, and the Super Cache changes were only applied to the file within /blog/, plus the .htaccess file contains multiple references to /blog/ (i.e. it appears to be configured to only rewrite within /blog/).

    I tried using the “string ignore”, but there are too many files to do it manually, and more are being created all the time. Is there perhaps a way to tell it to ignore all strings EXCEPT “/blog/” ? Maybe a way to use regex instead of standard positive match strings?

    Are there any other settings I could look into to ensure that Super Cache stays contained within /blog/?


Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Donncha O Caoimh


    I loaded your /index.php and it didn’t appear to be cached. If the file doesn’t include any WordPress files I can’t see how it could be cached.

    Hi donncha, I actually deactivated the plugin because I didn’t undertand why it was acting this way. If I activate the plugin write now, I see the following at the bottom of ‘/credit-cards.php’ (sorry, not index.php, because it redirects).

    <!-- Dynamic page generated in 0.524 seconds. -->
    <!-- Cached page generated by WP-Super-Cache on 2010-10-15 10:14:46 -->

    I also see ‘/credit-cards.php’ in the list of cached files in the Dashboard.

    The same happens to all pages of my site, not just those within /blog/. Some pages do have references to the WP loop, but this page certainly does not, so it’s a clean example.

    It doesn’t *appear* to affect the functionality of the site, but I can’t risk that the caching may have adverse affects for other users.

    Any idea why this might be happening? And any idea if I can use the “exclude string” setting to exclude all files in my site, and then “re-include” only those within /blog/?

    For the record, this is what “view mod_rewrite rules” is showing me:

    # BEGIN WPSuperCache
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    AddDefaultCharset UTF-8
    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
    RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
    RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/cache/supercache/%{HTTP_HOST}/blog/$1/index.html.gz -f
    RewriteRule ^(.*) "/blog/wp-content/cache/supercache/%{HTTP_HOST}/blog/$1/index.html.gz" [L]
    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
    RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
    RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
    RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/cache/supercache/%{HTTP_HOST}/blog/$1/index.html -f
    RewriteRule ^(.*) "/blog/wp-content/cache/supercache/%{HTTP_HOST}/blog/$1/index.html" [L]
    # END WPSuperCache
    Rules must be added to /home/froker/public_html/blog/wp-content/cache/.htaccess too:
    # BEGIN supercache
    <IfModule mod_mime.c>
      <FilesMatch "\.html\.gz$">
        ForceType text/html
        FileETag None
      AddEncoding gzip .gz
      AddType text/html .gz
    <IfModule mod_deflate.c>
      SetEnvIfNoCase Request_URI \.gz$ no-gzip
    <IfModule mod_headers.c>
      Header set Vary "Accept-Encoding, Cookie"
      Header set Cache-Control 'max-age=300, must-revalidate'
    <IfModule mod_expires.c>
      ExpiresActive On
      ExpiresByType text/html A300
    # END supercache

    I understand that this isn’t *supposed* to be happening, but the fact is, it is. Maybe there’s something weird about the way my site is set up, but it’s happening.

    All I really want to be able to do is explicitly tell WP Super Cache which files to include or not to include. Since all the files outside of my blog have very different filenames, I can’t rely on the normal exclude functionality that’s built on string matches.

    If instead I could say exclude any file that DOES NOT MATCH ‘*/blog/*’, my problem would be solved. Is that possible?

    Plugin Author Donncha O Caoimh


    So, your php files are loading the WordPress configuration? You could define the constant DONOTCACHEPAGE in pages that shouldn’t be cached.

    If every page loads WordPress, edit your wp-config.php and have it check the REQUEST_URI for /blog/. Set that constant if it’s not there.

    sounds like you mean do something like this:

    [in wp-config.php]
    if(strpos($_SERVER['REQUEST_URI'],'/blog')) define('DONOTCACHEPAGE',true);

    is that sufficient? i haven’t done much editing of wp-config before, so i want to be sure. and does it make more sense to add this to wp-config.php or wp-cache-config.php?

    thanks for your help!

    Plugin Author Donncha O Caoimh


    Do the opposite, “!strpos(…..” or it your blog won’t be cached! 🙂

    ah yes, haha. typo! this is why i will never work at google.

    i’ll give that a shot, thanks!

    worked like a charm!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WP Super Cache] Plugin is caching files outside of my blog’ is closed to new replies.