I am using W3-Total-Cache plugin, here is my plugin configurations :

enter image description here

I am trying to implement caching on my custom php file. I have created a folder (api) inside plugins directory. i.e /wp-content/plugins/api . It has a file get_users.php. It queries the database and returns all the registered users in json format. This is something similar to api where I make an api call to url : http://domain.com/wp-content/plugins/api/get_users.php It returns data in json format and I am using that data to display in moble app.

The problem I am facing is this url is not caching.

I am not able to see my url in the page_enhanced folder while other WordPress pages are shown properly.

When I am hitting the url in the browser I am getting the below header response attached in screenshot

My other pages, blog posts, home page are getting cached properly.

I am stuck here from a very long time.

  • Caching plugins will try to cache all requests that go through WordPress (as you say: pages, blog posts, home page). When you directly call a PHP file at http://domain.com/wp-content/plugins/api/get_users.php somewhere (which is considered bad practice), this completely bypasses WordPress and thus any caching plugin. I'd suggest leveraging the WordPress REST API instead.
    – swissspidy
    Jan 28, 2017 at 11:28

1 Answer 1


Caching is not magic, someone needs to write the code for it. Caching plugins will handle most basic page types in wordpress, but anything which is not a post will most likely need to have an explicit integration with the caching plugin, or just have its own caching.

side note: it is a big no-no to directly access php files that are in the wp-content directory. If this is part of a plugin, you should either use the ajax or the json end points for whatever you are doing. If it is for your own site, better to place the file at the wordpress root directory, or totally outside it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.