Title: Solution: Preload deleting supercache files on Windows stack
Last modified: August 30, 2016

---

# Solution: Preload deleting supercache files on Windows stack

 *  [mike.banavige](https://wordpress.org/support/users/mikebanavige/)
 * (@mikebanavige)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/solution-preload-deleting-supercache-files-on-windows-stack/)
 * 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://wordpress.org/plugins/wp-super-cache/](https://wordpress.org/plugins/wp-super-cache/)

Viewing 1 replies (of 1 total)

 *  [RFNM](https://wordpress.org/support/users/rfnm/)
 * (@rfnm)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/solution-preload-deleting-supercache-files-on-windows-stack/#post-6795934)
 * 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.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [RFNM](https://wordpress.org/support/users/rfnm/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/solution-preload-deleting-supercache-files-on-windows-stack/#post-6795934)
 * Status: not resolved