Title: wp_opcache_invalidate_file
Published: August 11, 2020
Last modified: April 28, 2025

---

# apply_filters( ‘wp_opcache_invalidate_file’, bool $will_invalidate, string $filepath )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_opcache_invalidate_file/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_opcache_invalidate_file/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_opcache_invalidate_file/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_opcache_invalidate_file/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/wp_opcache_invalidate_file/?output_format=md#wp--skip-link--target)

Filters whether to invalidate a file from the opcode cache.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/wp_opcache_invalidate_file/?output_format=md#parameters)󠁿

 `$will_invalidate`bool

Whether WordPress will invalidate `$filepath`. Default true.

`$filepath`string

The path to the PHP file to invalidate.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/wp_opcache_invalidate_file/?output_format=md#source)󠁿

    ```php
    if ( apply_filters( 'wp_opcache_invalidate_file', true, $filepath ) ) {
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/file.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/file.php#L2763)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/file.php#L2763-L2763)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/wp_opcache_invalidate_file/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_opcache_invalidate()](https://developer.wordpress.org/reference/functions/wp_opcache_invalidate/)`wp-admin/includes/file.php` |

Attempts to clear the opcode cache for an individual PHP file.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/wp_opcache_invalidate_file/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.5.0](https://developer.wordpress.org/reference/since/5.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_opcache_invalidate_file%2F)
before being able to contribute a note or feedback.