WP Ghost is fully compatible with Autoptimize. Autoptimize is a popular optimization plugin that minifies and aggregates CSS, JS, and HTML files to improve load times. To use both plugins together while keeping WP Ghost’s path security intact, you need to change Autoptimize’s default cache directory, then enable WP Ghost’s Change Paths in Cache Files option so the optimized files reference your custom paths. This guide walks through the complete configuration in 3 steps.
Autoptimize generates aggregated and minified CSS/JS files and stores them in a cache directory. These optimized files contain references to your original WordPress paths (/wp-content/plugins/, /wp-content/themes/). Without WP Ghost coordination, the optimized files expose your WordPress structure even though WP Ghost is active on the live pages. Additionally, the default Autoptimize cache directory (/wp-content/cache/autoptimize/) is predictable and reveals that you’re using Autoptimize. The fix is two-sided: rename the cache directory and tell WP Ghost to update paths inside cached files.
Configure Autoptimize to optimize and aggregate your CSS and JS files:
Tip: Aggregating files reduces HTTP requests but increases the size of each cached file. Test your site’s performance after enabling aggregation – if specific scripts break, exclude them from aggregation in Autoptimize’s settings rather than disabling the feature entirely.
The default Autoptimize cache directory /wp-content/cache/autoptimize/ is predictable and reveals that you’re using the plugin. Change it to a non-obvious name.
/wp-content/cache/autoptimize/ to something non-obvious like /wp-content/cache/static/ or /wp-content/cache/build/.Tip: Pick a directory name that doesn’t reference Autoptimize or any cache-related terminology. /wp-content/cache/static/, /wp-content/cache/build/, or /wp-content/cache/dist/ all work well. The goal is to make the directory look like a generic asset folder.
Now tell WP Ghost to rewrite the paths inside Autoptimize’s cached files. Without this step, your aggregated CSS/JS files still reference the original WordPress paths even though WP Ghost has changed them on the live site.
WP Ghost runs a background WP Cron job that processes cached files and updates the paths automatically. For complete configuration details, see Change Paths in Cached Files.
Important: After enabling this option, clear the Autoptimize cache so the next page load creates fresh optimized files with the updated paths. Go to Settings > Autoptimize and click Save Changes and Empty Cache. If WordPress Cron is disabled on your site, you can manually trigger the path update from WP Ghost’s settings.
wp-content/plugins and wp-content/themes. They should NOT appear – you should see your custom WP Ghost paths instead.autoptimize in the source. It should NOT appear if you renamed the cache directory in Step 2.The Autoptimize cache hasn’t been cleared since enabling Change Paths in Cache Files in WP Ghost. Go to Settings > Autoptimize and click Save Changes and Empty Cache. Visit a few pages while logged out to regenerate the optimized files with the updated paths.
This isn’t a WP Ghost issue – it’s a common Autoptimize problem when JS/CSS files have dependencies that break when combined. In Autoptimize settings, exclude the problematic scripts from aggregation using the “Exclude scripts from Autoptimize” field. Test which files cause the issue by excluding them one at a time.
WP Ghost uses WP Cron to process cached files in the background. If WP Cron is disabled on your site (common on sites using server-side cron), you can manually trigger the path update from WP Ghost’s settings. Alternatively, ensure your server-side cron is configured to run WordPress cron: */5 * * * * wget -q -O - https://yoursite.com/wp-cron.php >/dev/null 2>&1
Use the Safe URL parameter to bypass WP Ghost temporarily. If that doesn’t work, see the Emergency Disable guide to recover access via FTP.
Either order works, but the recommended sequence is: install Autoptimize first, configure optimization and aggregation settings, then install WP Ghost and enable Change Paths in Cache Files. This ensures Autoptimize’s settings are stable before WP Ghost starts processing the cached files.
Yes, whenever you change paths in WP Ghost. Cached files contain the old paths until regenerated. Clear the Autoptimize cache after any WP Ghost path change to ensure visitors see the updated paths immediately.
If you use Autoptimize with a CDN (Cloudflare, BunnyCDN, KeyCDN), you also need to purge the CDN cache after enabling WP Ghost path changes. The CDN serves cached versions of your optimized files from edge servers, which won’t reflect the new paths until purged.
Yes. WP Ghost is fully compatible with WooCommerce and Autoptimize works with WooCommerce too. Make sure Autoptimize doesn’t aggregate scripts that WooCommerce depends on for cart and checkout functionality – if those pages break, exclude the problematic scripts from aggregation.
No. WP Ghost writes rewrite rules to .htaccess (Apache) or hidemywp.conf (Nginx) and uses WordPress hooks for application-level changes. No core files are modified. Deactivating WP Ghost restores all defaults instantly.
WP Ghost with cache and performance plugins:
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.…