• mike.banavige

    (@mikebanavige)


    This post relates to supercache version 1.4.6

    When i first enabled the preload feature and manually ran a preload, the supercache filled with files for all of my sites pages. Things were looking good. But the next day when checking the Contents of the cache, there were zero supercache files. hmmm…

    In reviewing the debug log, the supercache files appeared to be getting requested, but then at the tail end of the preload process, they were all being deleted as part of a cleanup process.

    Have identified a bug for the windows stack users where windows file paths use \ (backslash) as a path separator and linux would use / (forward slash) as the separator. Linux sites should be unaffected.

    In the file wp-cache-phase1.php on line 618 there is a test to make sure that supercache files in $dir (about to be deleted) are actually stored in the defined supercache path $cache_path.

    For a windows user, this test always fails due to how the different OS’s define path separators.

    For me, the failing string comparison was this string:
    D:\Inetpub\www.myawesomesite.com\wp-content\cache\

    being compared to this string:
    D:\Inetpub\www.myawesomesite.com\wp-content/cache/

    Windows file operations seem fairly tolerant of intermixing \ with / as path separators so the issue is really just the string compare which i worked around as follows (trying to make sure the code would work regardless of OS):

    Line 618 of wp-cache-phase1.php changed from:
    if ( substr( $dir, 0, strlen( $cache_path ) ) != $cache_path )

    to:
    if ( str_replace("\\","/",substr( $dir, 0, strlen( $cache_path ) ) ) != str_replace("\\","/",$cache_path) ) {

    This insures the both $dir and $cache_path are using the same path separator character / when doing the string compare.

    Preload now working exactly how I’d hoped.

    Hopefully this will help anybody else (on a windows stack) who had trouble with Preload and might make it into the next release/build.

    https://www.ads-software.com/plugins/wp-super-cache/

Viewing 1 replies (of 1 total)
  • Many thanks Mike, preload now seems to be working for me under IIS7.

    I’m on v1.4.7 and your suggestion isn’t included in wp-cache-phase1.php.

Viewing 1 replies (of 1 total)
  • The topic ‘Solution: Preload deleting supercache files on Windows stack’ is closed to new replies.