v3.6.0 Progress Report – Part 2

Posted April 12, 2013 by Purefan in phpFox v3, Company

In the past couple of weeks we have focused on improving Phpfox in ways that we had only sporadically done in the past, more specifically performance, search engine optimization and security, to me personally these are the three pillars of a solid base script and I am really happy to be part of this.

In terms of performance we have taken two main fronts, first we looked at the database logs and worked with the slow query log to find inefficient queries and worked on improving them, in some cases it meant adding an index in the database and in others just changing the way the query worked; second, we implemented a more aggressive caching approach, we now cache things like the feeds (with their likes and comments), user information, list of friends (mutual friends, random friends displayed in the profile,…), recent viewers to a profile, events, user ratings, featured users,…. This allowed us to drop the calls to the database dramatically. There are two ways a cache item can be refreshed (meaning it needs a call to the database), one is that the cache expiration time is reached and the other is that the item changed, for example if a feed does not get new comments it will not be reloaded from the database, you can view it many times and it will be “free”, but if you add a comment then it will require a database call and then be cached, subsequent views will be “free”.

In regards to minifying CSS and JS we tried a few ways, a couple did work very nicely but for custom themes it wasn’t so easy to profit from this benefit, so we opted for generating Master files (one JS and one CSS), the benefit is that JS and CSS code used throughout the site will be cached separately by the browsers, and smaller files are quicker to download for the browsers. Besides the Master files we also create a css and js file specific to the page being loaded, which ends up being a much smaller file because it does not contain the code from the Master. To further illustrate this let us say that in a brand new site a user goes for the first time to PageA, at this point the script generates the Master files and the CSS and JS files specific to PageA (4 files created), the user then goes to PageB and the script only creates the CSS and JS files specific to PageB (2 files) because the Master files were already generated, if the user then goes back to PageA the script will not create the files again because this was already done. This is different than in current versions since we create more files, but the benefits of this are well worth it since more code is cached is more efficiently both by the script and by the web browsers. Still, to place the cherry on top, these files can now automatically be pushed to CDN which was not possible in previous versions. A last improvement we made in this regards was to rename the cookie, the new name is “chocolate_sparkles” and it seems that web browsers like this better and run to get it faster than before.

Current add-ons and themes will remain compatible. This minification routine is intended to work with any theme in use: custom themes, edited default themes and themes using the custom.css will all work automatically, without any change needed by designers or developers.

We also implemented deferring of images, the effect is that instead of loading full images the script will send a tiny little image (36 bytes) and when the browser finished loading the page it loads the full image, in reality this only changes the order in which items are loaded and displayed to the user, making for a smoother experience as the page seems to load faster.

Of all the changes the only one that is not bound to a setting is to move the JS files to the end of body, but using the new minification routines and everything else can be switched off from the AdminCP.

For now this is all I have to report, we will continue keeping you updated with the progress made, our next step is to focus on SEO and Im sure this will be a great adventure.

All the best!