---
title: Standalone Script for Clearing APC Cache
date: 2010-06-01T12:48:59+00:00
modified: 2010-06-01T12:52:58+00:00
permalink: https://kaspars.net/blog/standalone-script-for-clearing-apc-cache
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
category:
  - Development
post_tag:
  - How to
  - Snippet
---

# Standalone Script for Clearing APC Cache

After upgrading WordPress to a new version, you might need to clear the APC opcode cache. Here is a simple script that you can store in the root of your website, for example, `clearapc.php`:

```
if (function_exists('apc_clear_cache') && $_GET['pass'] == 'secret') {
        if (apc_clear_cache() && apc_clear_cache('user'))
                print 'All Clear!';
        else
                print 'Clearing Failed!';

        print '';
        print_r(apc_cache_info());
        print '';
} else {
        print 'Authenticate, please!';
}
```

Then call the script via `http://example.com/clearapc.php?pass=secret`

Instead of using `?pass=secret`, you might well call the filename something that is hard to guess: `clearapc93920.php`