Fast, Reliable & Affordable Web Services
Highlights
  • email marketing ...
  • content management ...
  • fastest VPS hosting ...
  • new SEO techniques ...
  • Online business drivers ...

converting shopp and wordpress to serve cookieless static content on a sub-domain

It is well documented that asset files that don’t need cookies are wasting precious time in the round trip from user request (browser request) through to the full rendering a web page.

If you are reading this then I’m assuming that you have a good understanding of a website served from and LAMP setup and therefore a good understanding of Linux, Apache, MySQL and PHP. This is not a recipe, but a set of notes on how we achieved certain optimisations for our websites.

If I setup a wordpress site with shopp (the popular e-commerce plugin) and any number of well known themes (for example from yoo of simple themes [there are so many good ones out there]), then I can expect to end up with a webpage that has as many 100-200 assets. Assets being images, style sheets, javascript etc. Each asset makes a request to the same server as the web pages itself. And, each request will contain sever cookies. Without cookies the request header contains perhaps 128-256 bytes of data, but with cookies it be, for example 1K more (1024 bytes). If you think about the round of requesting a web page 1k doesn’t seem that much, but if you multiply that by 100 because you are making 100 requests for assets, it is still only an extra 100K. However, most of us are on ADSL connections and our upload speed is perhaps 20% of our download speed. So, in terms of user time spent uploading 100K is the same as downloading an additional 500K of completely unneeded material.

Obviously this can vary from site to site, but the principal holds.

Google Talk about this is here.

There are two things you can do about this:

  1. Reduce the number of assets by concatenating all JavaScript files into one file and all CSS files into one file
  2. have the assets served from another domain or subdomain. This stops the request header from including any cookies passed to the browser.

You can concatenate files yourself or use a tool to do it for you such as W3 Total Cache (see minify).

If you are using a cache for wordpress and I tend to like W3 Total cache, then by caching dynamic pages and serving them as static HTML, you have to be careful with certain things. If you have any content on each page that is specific to that user then that needs to be fetched by AJAX. On my e-commerce sites the shopping basket details displayed on each page are handled this way and I consider it well worth the extra time coding to all page caching. All other aspect of each page are the same between users and only change when we alter product particulars, such as price, description or images – perfect for caching. See shopp’s instructions on caching.

Shopp offers an AJAX cart (and side cart), but it doesn’t offer an AJAX update of the number of items and their value in the the cart, so that it has to be coded.

If my site is on www.mysite.com, then I have setup static.mysite.com and pointed it to part of the same webroot by creating a symbolic link to the wp-contents directory.

In addition you will need to convert the URLs returned from shopp(‘product’ in the shopp templates files to use the static domain: be careful not to ignore the https case, you don’t want mixed content on your secure pages.

 

 

 

 

 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.