Ensure your custom WordPress paths work correctly with caching plugins by enabling Change Paths in Cached Files in WP Ghost. Caching plugins store static copies of your CSS, JS, and HTML. Those cached files still contain default WordPress paths like /wp-content/ and /wp-includes/. Without this feature, your cache serves pages with original paths even though WP Ghost has changed them – revealing WordPress to bots through the cache layer. One toggle fixes this.
When a caching plugin is active, it creates static copies of your pages, CSS, and JavaScript files and stores them in a cache directory (typically /wp-content/cache/). These cached files are served directly to visitors, bypassing WordPress’s dynamic processing – which is exactly how caching improves performance.
The problem is that WP Ghost’s real-time path rewriting happens during WordPress’s dynamic processing. If the caching plugin serves a pre-built static file, WP Ghost doesn’t get the chance to rewrite the paths in that file. The visitor gets the cached version – with original WordPress paths intact.
Change Paths in Cached Files solves this by scanning the cache directory in the background and rewriting paths inside cached CSS, JS, and HTML files. It runs automatically, doesn’t affect page load speed, and ensures that cached pages serve the same custom paths as dynamically generated ones.
Caching is essential for performance. But without this feature, it can undo your entire path-security setup. Here’s what’s at stake for your hack prevention strategy:
Cached HTML contains the original paths. When your caching plugin builds a static HTML file of a page, it snapshots everything – including CSS and JS references that point to /wp-content/themes/, /wp-content/plugins/, and /wp-includes/. Those references are baked into the cached file. Every visitor who loads the cached page sees default WordPress paths in the source, regardless of what WP Ghost has configured.
Cached CSS and JS files keep original references. Even if the HTML paths are rewritten, the CSS and JS files inside the cache may still contain internal references to default WordPress paths – font URLs, image paths, and import statements that point to /wp-content/. These are secondary leaks that scanners can use to confirm WordPress.
The cache directory itself is a fingerprint. Most caching plugins store files in predictable directories like /wp-content/cache/, /wp-content/cache/wp-rocket/, or /wp-content/litespeed/. If these directories are visible in the page source, they reveal both WordPress and the specific caching plugin you’re using. WP Ghost can hide these directories too (see Step 3 below).
Three features work together: activate path rewriting in cache, optionally set a custom cache directory, and hide the cache directory URL.
WP Ghost immediately begins scanning the cache directory and rewriting paths in all cached files. This process runs in the background and takes up to a minute to complete. It does not affect page load speed.
Most caching plugins store files in /wp-content/cache/ and WP Ghost detects this automatically. If your caching plugin uses a non-standard directory, you need to tell WP Ghost where to find the files.
Even after paths inside cached files are rewritten, the cache directory URL itself (like /wp-content/cache/wp-rocket/) may still appear in your page source. This reveals both WordPress and your specific caching plugin. WP Ghost’s URL Mapping feature can rename the cache directory URL to something generic.
/wp-content/cache/) to a custom name.After this, your page source shows the custom directory name instead of the caching plugin’s default path. No more /wp-rocket/ or /litespeed/ in your source code.
WP Ghost is pre-configured to work with major caching plugins. For the most common ones, it automatically detects the cache directory and handles path rewriting without additional setup:
LiteSpeed Cache – WP Ghost automatically detects the LiteSpeed cache directory and hides it to prevent exposure.
WP Rocket – Paths are automatically modified in WP Rocket’s cached files. The WP Rocket cache directory can be hidden via URL Mapping.
Autoptimize – WP Ghost automatically identifies Autoptimize’s cache path and rewrites paths in optimized CSS and JS bundles.
For other caching plugins, WP Ghost uses universal detection to manage path changes. See the full cache plugin compatibility list for details.
WP Ghost rewrites cached files in the background, which takes up to a minute. If the page was loaded before the rewrite completed, you’ll see original paths. There are three solutions: enable cache preloading in your caching plugin (this forces cache regeneration so WP Ghost can process the files immediately), click the Change Paths Now button in WP Ghost to trigger a manual rewrite, or simply wait a few minutes and test again in a private browser window.
This is expected behavior. When you clear the cache, the caching plugin regenerates fresh static files from WordPress’s dynamic output. WP Ghost then needs to scan and rewrite these new files. The process happens automatically in the background. If you need immediate results after a cache clear, click Change Paths Now in WP Ghost or enable cache preloading.
If you’ve lost access or something broke, check the emergency disable guide, use the rollback settings, or add a constant in wp-config.php to disable WP Ghost temporarily.
No. The path rewriting happens in the background after cache files are generated. It doesn’t run during page loads. Visitors experience the same cached performance as before – the only difference is that the cached files now contain custom paths instead of default WordPress paths.
Yes, if you want WP Ghost’s path changes to be effective. Without this feature, your caching plugin serves static files with original WordPress paths, bypassing WP Ghost’s real-time rewriting. This is one of the most common reasons people think WP Ghost “isn’t working” – it’s working fine for dynamic pages, but the cache is serving pre-built files with old paths.
If you don’t use any caching plugin, you don’t need this feature. WP Ghost rewrites paths in real time during WordPress’s dynamic page generation. This feature is specifically for sites that serve pre-built cached files.
Yes. WooCommerce pages that are cached (like product listings and category pages) have their paths rewritten in the cached files. Dynamic WooCommerce pages (cart, checkout, my account) are typically excluded from caching by the cache plugin itself, so WP Ghost handles them through real-time rewriting. WP Ghost is fully compatible with WooCommerce.
No. WP Ghost modifies the contents of cached files generated by your caching plugin – not WordPress core files. The original CSS, JS, and PHP files in wp-content/, wp-includes/, and WordPress core remain completely untouched. Only the static copies in the cache directory are rewritten. Deactivating WP Ghost and clearing the cache restores everything to default.
Ensure your caching and path-security work together:
Replace the default wp_ database prefix with a random one to protect against SQL injection…
Change the WordPress uploads directory path with WP Ghost (rewrite rules, no files moved) or…
Configure WP Ghost with WP Rocket cache. Enable file optimization, Change Paths in Cache Files.…
https://youtu.be/6ylhojSi-_E In this video, we’ll explore why website security matters and what can happen if…
The security of your WordPress site depends on multiple factors, such as the strength of…
Step-by-step guides to connect WP Ghost 2FA with Google Authenticator, Authy, Microsoft Authenticator, or LastPass.…