Multiple Configurations, Multiple Cache

I have been testing a change on my website for a week now, and everything appears to be stable. Before I get into the fix, let me give a little background to the issue. Xaraya has long had the ability to run multiple configurations for domains. In layman's terms, the ability to run multiple websites off one codebase. Each of my websites are running directly from one clone of our repositories. My guess is that is not uncommon with other blogging or CMS software. The code that we use in Xaraya is very easy and pretty much kept in our configuration:

The code is extremely simple to read and understand. First we are looking for $_SERVER['HTTP_HOST'] which returns our host name. Once we have that, we strip the var down to just the name and load a config file from outside of our normal arena. If your application's configuration is not hard coded with paths or your application doesn't read / write directly to the configuration this method should work for most.

The problem that I was facing is in Xaraya we use different cache techniques to improve performance. We cache each template. We also have the Cache Manager do the dirty work with the pages and blocks that are presented. Each of these cache files are held in our var directory. This was where the bottleneck was happening on this website. Each time someone hit another domain that my codebase was supporting, I was over-writing the cache files. I would see a noticeable difference in performance on the first time I hit the site to the pages I visited.

Luckily in Xaraya we do not hardcore the path for the var directory. We can specify where it is kept for security. With that in mind, I used the same code in our var key file to change the location to be am individual cache as well. Now, I can support separate cache set-ups. For Xaraya 1.0 this should be good enough, however I would like to take this just a bit further on the 2.0 series. We know the core is always going to be the same for the application. However, I would also like to load only certain themes and only certain modules into Site A and Site B, but have the full contingent on Site C, and oh by the way, I would like to manage all of my sites from a single location rather than multiple. That will take more than a 10 line hack to work well, unfortunately.

Print | Related