Smarter Programming
Over the past month or so I have been working on a new web site which has a lot of content, some of it freely available and some of it for members only. One of the specifications I received early in the project was that I should try to make the pages mostly static to allow greater caching capabilities and hence - reduce server load.
This hasn't really worked in the past because we have had to start the session prior to loading each page and checking if the user is a logged in member to determine what content the user should or should not see. As we need to keep cookies to a minimum, and sessions use cookies, I have had to find new ways to perform old tricks. Early in the project the programming department had a meeting and discussed various ways of achieving these aims, some of which I have been able to successfully implement.
The way I have been able to get around this is through the use of AJAX. I will explain what I mean using an article page as an example. As I said above, some articles are freely available while some are only available to members. In the past, if the article is "members-only" and the user is not logged in, then an extract of the article is displayed along with a prompt for the user to log in to view the remainder of the article. Of course, if the article is free, then it is just displayed. In order to perform this check, we need the session.
So, what I have now done is to load the article extract only on the page and then trigger an AJAX call which can determine whether the user is logged in and return only the article content if appropriate. What this means in practical terms is that all of the header and footer and associated dressing around the article (including images, Javascript libraries and CSS) is loaded just once and is cached to reduce server load. An extract of the article is also loaded and cached and provides the content necessary for search engines. Then, the content which is not static (ie. the full article depending on whether it can be displayed) is retrieved from the server and also displayed. Of course, this initially means two server requests instead of one, but subsequent requests for the same page will only result in one request which will be for the content only, as all other resources have been cached.
Of course, this idea is not only relevant for articles but can be extended to any feature where content depends on details about the user which may or may not be known. Such features can include showing events in the user's local area or can even be as simple as determining whether or not the member login form should be displayed. At the end of the day, hopefully, these changes will mean faster page loading times for users while not impacting on the user experience.
Search By Theme
- The Wondrous Wide Web (20 posts)
- Search Engine Optimisation (27 posts)
- Programming and Coding for the Web (26 posts)
- Web Design (44 posts)
- Social Media (1 posts)
- Marketing (16 posts)
- Inside Ireckon (15 posts)
- Content Management Systems (11 posts)
- Conversion Optimisation (4 posts)
- Recent Stuff (7 posts)
- Web Gadgets (2 posts)
- Daily Inspiration (1 posts)
- Darryl's Blog



What do you think?