How does cache and js/css aggregation work?

Development
  1. 6 months ago

    I am struggling to find how links like : http://esotalk.org/forum/cache/js/jquery,jquery.misc,jquery.history,jquery.scrollTo,global.js? work. Can someone explain what controller is being called?

    I am investigating this because I am having a problem having the PHP write into my cache folder.

    (Note: can we please get rid of BBCode and use markdown please? (github flavor, extra please))

  2. Please add a "Development" channel too... :)

  3. BBCode is still the most popular lightweight markup language to forum softwares. Also, there may be no need to add the development channel, for this forum is already for development.

  4. Thirtysixway

    Nov 16 Moderator

    Find this post petsagouris I am struggling to find how links like : http://esotalk.org/forum/cache/js/jquery,jquery.misc,jquery.history,jquery.scrollTo,global.js? work. Can someone explain what controller is being called?

    I am investigating this because I am having a problem having the PHP write into my cache folder.

    (Note: can we please get rid of BBCode and use markdown please? (github flavor, extra please))

    Toby posted a blog entry about how this works, http://esotalk.org/blog/index.php/2011/11/05/aggregating-javascript-css/

  5. Toby

    Nov 16 Administrator

    Yep. Basically, the controller collects a list of all of the JS/CSS files to be included on the page, and then generates and caches a .js or .css file containing all of those files. See lines 675 to 760 of lib/ETController.class.php.

  6. Toby

    Nov 16 Administrator

    Find this post petsagouris Please add a "Development" channel too... :)

    Done.

  7. Yep I am aware of what the file aggregation does. I've already found where those things happen. What I don't seem to get is how is the /forum/cache/ is mapped onto these functions. I saw that there is something going on in the index.php but I could link from there to the ETController.class.php

  8. Toby

    Nov 16 Administrator

    It's simply served up as a physical file; no mapping takes place. The RewriteCond %{REQUEST_FILENAME} !-f line in .htaccess prevents requests to existing files from being rewritten altogether.

  9. Edited 6 months ago by petsagouris

    That solves it then.

    1. A general HTTP Request is received
    2. Esotalk checks the cached files.
    3. If there aren't any, and if the configuration file config.defaults.php says we must cache, the contents of those files are aggregated and saved in cache/.
    4. The files are served by apache, no PHP processing them after the initial aggregation.
  10. Toby

    Nov 16 Administrator

    Correct.

or Sign Up to reply!