Title: Files with .css.php and .js.php extensions not getting cached
Last modified: August 20, 2016

---

# Files with .css.php and .js.php extensions not getting cached

 *  [mvandemar](https://wordpress.org/support/users/mvandemar/)
 * (@mvandemar)
 * [15 years ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/)
 * My client is using the Featured Content Gallery plugin, which uses 2 resource
   files that are actually generated via php:
 * wp-content/plugins/featured-content-gallery/scripts/jd.gallery.js.php
    wp-content/
   plugins/featured-content-gallery/css/jd.gallery.css.php
 * These files both hook into WordPress and query the database, and happen to be
   the 2 most often requested pages on the site. For some reason it does not appear
   as if W3 Total Cache is actually caching them though. I tried adding the file
   names to the “Cache exception list” section (which by description will “Cache
   the specified pages / directories even if listed in the “never cache the following
   pages” field.”) just in case, both by adding just the filename and by adding 
   the path + filename, but no difference. I tarred up the entire cache of the site,
   downloaded it, and grepped for strings within each file. There were no results
   for either, so I know for sure that they are not being cached.
 * Any help on this would be appreciated. Thanks.

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

 *  Plugin Contributor [Frederick Townes](https://wordpress.org/support/users/fredericktownes/)
 * (@fredericktownes)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097427)
 * Sorry .php files cannot be cached. They are presumed to be dynamic.
 *  Thread Starter [mvandemar](https://wordpress.org/support/users/mvandemar/)
 * (@mvandemar)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097429)
 * Then that is a bug on your end, Frederick. It is an incorrect presumption. How
   would I fix this?
 *  Plugin Contributor [Frederick Townes](https://wordpress.org/support/users/fredericktownes/)
 * (@fredericktownes)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097438)
 * It’s not about right or wrong or even a bug, it’s about safe assumptions and 
   programming best practices (which .js.php or .css.php is not because of how web
   servers work).
 * Anyway, you can try to append those extensions to the custom file list for example.
 *  Thread Starter [mvandemar](https://wordpress.org/support/users/mvandemar/)
 * (@mvandemar)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097439)
 * Frederick, I was referring to the fact that you have a box to enter files that
   should always be cached, and it ignores files you enter that have a php extension,
   then that would be a bug.
 *  [onelife1985](https://wordpress.org/support/users/onelife1985/)
 * (@onelife1985)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097451)
 * I don’t get it either.. why would that be a bug? most systems (even a system 
   of humans) are based on assumptions and decisions. In this case, it is **your**
   assumption to cache php. Personally I wouldn’t want any of my php files to be
   cached since I’m using php for computational purposes.
 *  Thread Starter [mvandemar](https://wordpress.org/support/users/mvandemar/)
 * (@mvandemar)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097452)
 * [@onelife1985](https://wordpress.org/support/users/onelife1985/) – no, it’s my
   assumption that if you list a file in a box that says “always cache these file”,
   it will always cache those files.
 * Besides – pretty much the entire WordPress platform is used for computational
   purposes. There is no point in caching static pages… they are technically already“
   cached”, as almost no processing power is required to serve them. It’s the whole
   purpose of the caching plugin to store what would otherwise be dynamic pages,
   thus reducing the load on the server.
 *  [onelife1985](https://wordpress.org/support/users/onelife1985/)
 * (@onelife1985)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097453)
 * [@mvandemar](https://wordpress.org/support/users/mvandemar/) you have a good 
   point there. But still I would recommend you to look further up at Frederick’s
   comment.. As he is the project manager W3TC, the system is based on the assumptions
   of his team (maybe community as well?), right?
 * **Exactly.. **“It’s the whole purpose of the caching plugin to store what would
   otherwise be dynamic pages, thus reducing the load on the server.”
 * What is cached is the result right? not the computational part (or else the algorithm)..
   You don’t want the server to go through the computational part multiple times
   and that’s why caching is used, to produce only once.
 * Based on Frederick’s comment above, php files are considered to be part of the
   computational part.
 *  Thread Starter [mvandemar](https://wordpress.org/support/users/mvandemar/)
 * (@mvandemar)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097454)
 * [@onelife1985](https://wordpress.org/support/users/onelife1985/) – we’re not 
   talking about caching something that is one section of a greater page. It’s the
   end product of a single output, namely either css or javascript, that just happens
   to have a .php extension. Therefore it should cache the output of those pages.
   And, again, regardless of the extension, if there is an “always cache these files”
   box that doesn’t always cache those files, that’s a bug. I am really not sure
   why you are arguing this point.
 *  Plugin Contributor [Frederick Townes](https://wordpress.org/support/users/fredericktownes/)
 * (@fredericktownes)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097471)
 * The extension of those of .php files is .php files, just because they have a 
   prefix containing some other format does not mean that they are not generated
   dynamically. The final suffix of a file is intended to indicate what that file
   is or what it can do. I’m not going to change the settings, if you know what 
   your site is doing you can add the settings yourself.
 *  Thread Starter [mvandemar](https://wordpress.org/support/users/mvandemar/)
 * (@mvandemar)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097472)
 * Frederick if you don’t want to fix it then that is of course your decision, it
   is your plugin. But it is still a bug if you have a feature that does not do 
   what the description says that it does.
 *  Plugin Contributor [Frederick Townes](https://wordpress.org/support/users/fredericktownes/)
 * (@fredericktownes)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097473)
 * I don’t know why you think that I should assume a .js.php file is a static .js
   file. Are you sure you understand the implications of your request?
 *  Thread Starter [mvandemar](https://wordpress.org/support/users/mvandemar/)
 * (@mvandemar)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097474)
 * Frederick, I am not asking you to assume anything. Why would you? On the other
   hand, if someone enters in the name of a file inside of the text area that says“
   Always cache these file”, then why wouldn’t you cache them? I don’t understand
   what you aren’t getting… the instructions don’t say “Always cache these files,
   but we’re going to ignore your request if they have a php extension”, no… they
   say “Always cache these files”. Why does it make sense to you to have that text
   area there, and then ignore it?
 * If they were .html or .js files then there would be no need to cache them in 
   the first place, they would already be static. Literally nothing about your argument
   is making any sense.
 *  Plugin Contributor [Frederick Townes](https://wordpress.org/support/users/fredericktownes/)
 * (@fredericktownes)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097476)
 * So be it.
 *  Plugin Contributor [Frederick Townes](https://wordpress.org/support/users/fredericktownes/)
 * (@fredericktownes)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097479)
 * Anyway, .php scripts usually dont initialize WP engine at all, often they include
   wp-load.php. As a result, no actions are called and plugins dont have a chance
   to do anything with output, so they can’t be cached. So I suggest to use some
   caching in your code. The best would be to write .css via a plugin (and update
   it based on actions, etc) and then just include pure .css later, instead of including.
   php script as css.

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

The topic ‘Files with .css.php and .js.php extensions not getting cached’ is closed
to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 14 replies
 * 3 participants
 * Last reply from: [Frederick Townes](https://wordpress.org/support/users/fredericktownes/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/files-with-cssphp-and-jsphp-extensions-not-getting-cached/#post-2097479)
 * Status: not resolved