![]() |
![]() |
||||||
|
|||||||
Content Management > Static vs. Dynamic Content posted on 12:35 PM, December 24, 2008
This document provides an overview of the differences between static and dynamic content, how ExSite manages these, and various tricks you can use to mix and match them. Static ContentStatic content is published to regular files on your server and handled using the simplest methods available to the web server. The advantages of static content are:
However, it also has the following disadvantages:
Dynamic ContentDynamic content is generated for you at the time you request the page. The document you view exists only for you at that moment; if viewed by someone else at the same time, or by you at a slightly different time, you could get something different. Dynamic content is good for:
However, dynamic content has the following disadvantages:
Default ViewEvery page can declare whether it is static or dynamic. This determines the default view of the page, for example the initial view of the page when you first navigate to it from a menu. Static is the most efficient method, but some pages are best set to a dynamic view, because their contents change rapidly or unpredictably. For example, forums can be updated at any time by readers, so a dynamic view works best to display the current comments. Private (member-only) pages are dynamic by default, because they display different content depending on who is viewing them. Switching from static to dynamicPages in ExSite are not either static or dynamic, but can switch between these modes as needed. The static URL to a page will be something like: http://foobar.com/somepage.html whereas the dynamic URL will be something like: http://foobar.com/cgi/page.cgi?_id=123 or http://foobar.com/cgi/page.cgi/somepage.html If available, the static representation is used as the default page view because it is more efficient, but it will automatically switch to dynamic if necessary. Pseudo-Dynamic PagesThere are a few tricks for getting some of the benefits of a dynamic page, while using a published static HTML file that is served like a static page. DHTML (client-side dynamic content)This method requires that you use Javascript to modify your content, allowing for a small amount of flexibility in varying what you display to your viewer. One example in ExSite is the Login plug-in, which detects whether you are logged in or not, and displays either a login or logout link. This allows normal static pages to adjust their displayed functions depending on the viewer, without actually executing any server code or connecting to your database. Scheduled republishingThis method uses automatic republishing tools to regenerate a static page at regular intervals. That allows the static page to be updated with current content, without the webmaster having to log in and manually republish every time something new happens. This method is good for general content that changes frequently, but will not work for user-specific content that changes for each viewer. AJAXThis method uses AJAX to dynamically fetch certain page elements and insert them into a published static page. For example, a static home page could include an AJAX-generated index of the most recent user comments from the forums. Such pages are partially static and partially dynamic. Robots will generally ignore the AJAX calls, and get only a static page. Pseudo-Static PagesSimilarly, there are some tricks you can use to make it appear that a page is static, when in fact it is fully dynamic: Clean URLswith this method, the page indexing information is passed as path data rather than query data in the URL. A dynamic page URL like http://foobar.com/cgi/page.cgi?_id=123 will become something like: http://foobar.com/cgi/page.cgi/somepage.html This resembles the style of URL used for static pages, and may get you some of the caching or SEO benefits reserved for static pages. A sharp eye will still spot the "/cgi/page.cgi" part of the address, and recognize that as characteristic of dynamic pages. You can use Apache's mod_rewrite tools to edit this out of the URLs, if that concerns you. Note that clean URLs are slightly more costly to use, because they require more database lookups to find the page than the default URL style. Prepublishing Dynamic PagesWith this method, all pages are published to disk, whether static or dynamic. However, for the dynamic pages, the dynamic elements of the page (namely the plug-ins) are left unresolved. In the published page's HTML file, they appear as CMS tags. If the page is viewed as a normal static file, those tags are treated as HTML comments and they do nothing - the plug-in area will appear blank. If, however, the page is viewed using the clean URL method (above), ie. http://foobar.com/cgi/page.cgi/somepage.html then ExSite will display the published HTML file, and dynamically expand the remaining plug-ins on the page. Mod_rewrite can be used to translate the "static" URL http://foobar.com/somepage.html to the dynamic URL noted above. If any of the pages are truly static, they will still display correctly if they are translated to the dynamic URL. That means it is quite safe to rewrite all URLs to the dynamic form. Dynamic Content ObjectsWe have been discussing page views above, but it is also possible to view particular images or files (non-HTML pages) either dynamically or statically. If a content object is published to disk, it will have a normal URL such as: http://foobar.com/_Library/docs/somefile.pdf (The specifics of the URL will vary depending on whether the file is placed in a library, template, or normal page.) The same content object can also be viewed dynamically, eg: http://foobar.com/content.cgi/somefile.pdf?id=789 The advantage of dynamic content views is that they can be restricted to certain users (eg. members-only documents). |
AnnouncementsKeyword Tags |