Title: Clear cache programmatically
Last modified: February 14, 2019

---

# Clear cache programmatically

 *  [vijantis](https://wordpress.org/support/users/vijantis/)
 * (@vijantis)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/clear-cache-programmatically-4/)
 * For one of our websites we import data via a php script. Depending on the import,
   we need to manually clear the entire cache, or selected pages only.
 * Is there a way to do this, preferably directly in php (without WordPress interfaces)?
   
   Is it sufficient to simply delete (some) files?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [G](https://wordpress.org/support/users/gnetworkau/)
 * (@gnetworkau)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/clear-cache-programmatically-4/#post-11208174)
 * Yes you can simply delete the files.
 * I don’t do it via php, but you can, check [here](https://www.bing.com/search?q=delete+files+using+php).
 * For clearing cache of individual pages, sites, or entire cache – when needing
   to refresh content – I use cronjobs. Commands like these will do the job:
 * Clear entire cache
    `rm -rf /full/path/to/wp-content/cache/supercache >/dev/null
   2>&1` Clear cache of one site `rm -rf /full/path/to/wp-content/cache/supercache/
   domain.com >/dev/null 2>&1` Clear cache single page `rm -rf /full/path/to/wp-
   content/cache/supercache/domain.com/some-url >/dev/null 2>&1`
 * NOTE: Make sure to use the full path
    Added >/dev/null 2>&1 at end of command
   to stop feedback from cron
 *  [Saša](https://wordpress.org/support/users/stodorovic/)
 * (@stodorovic)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/clear-cache-programmatically-4/#post-11209258)
 * There is similar question – [https://github.com/Automattic/wp-super-cache/issues/628](https://github.com/Automattic/wp-super-cache/issues/628).
 * Other solution is [wp-cli](https://wp-cli.org/) and package [wp-super-cache-cli](https://github.com/wp-cli/wp-super-cache-cli).
   You can use this command: _wp super-cache flush_
 * I often use wp-cli and I’m contributor for wp-super-cache-cli. It’s very useful
   tool. If you find new issue then please report and I’ll try to fix it.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Clear cache programmatically’ 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/)

 * 2 replies
 * 3 participants
 * Last reply from: [Saša](https://wordpress.org/support/users/stodorovic/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/clear-cache-programmatically-4/#post-11209258)
 * Status: not resolved