WordPress.org

Forums

W3 Total Cache
Files with .css.php and .js.php extensions not getting cached (15 posts)

  1. mvandemar
    Member
    Posted 4 years ago #

    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.

  2. Frederick Townes
    Member
    Plugin Author

    Posted 4 years ago #

    Sorry .php files cannot be cached. They are presumed to be dynamic.

  3. mvandemar
    Member
    Posted 4 years ago #

    Then that is a bug on your end, Frederick. It is an incorrect presumption. How would I fix this?

  4. Frederick Townes
    Member
    Plugin Author

    Posted 4 years ago #

    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.

  5. mvandemar
    Member
    Posted 4 years ago #

    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.

  6. onelife1985
    Member
    Posted 4 years ago #

    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.

  7. mvandemar
    Member
    Posted 4 years ago #

    @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.

  8. onelife1985
    Member
    Posted 4 years ago #

    @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.

  9. mvandemar
    Member
    Posted 4 years ago #

    @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.

  10. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  11. mvandemar
    Member
    Posted 3 years ago #

    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.

  12. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    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?

  13. mvandemar
    Member
    Posted 3 years ago #

    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.

  14. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    So be it.

  15. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • W3 Total Cache
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic