Skip navigation

More Caching Tips

To reduce problems with caching coherency and site synchronization, always reference objects the same way from every page. Don’t use the /directory/image.ext format for one page and the absolute URL for another page. Use the same URL for shared images, server-side include code, and plugins.

Try to use No-Cache or Expires headers to cache large or static images, but leave at least one object (e.g., a .gif image, a small company logo) uncached so that you can track user visits. Using the same image, logo, or navigation bar across multiple pages not only gives your site a consistent, professional look but results in the caching of these images. As users navigate your site, pages will load quickly and data will remain fresh.

If you repeatedly access an object in script loops, consider storing the object as a user variable, which the system will cache. Don’t force a server round-trip for every loop iteration just to look up the object.

Whenever possible, use Active Server Pages (ASP). If a page has an .asp extension, the server must reprocess the file each time a client requests it. When the server receives a page request, it checks the page extension. If the extension is .htm or .html, the server passes the page to the client. If the extension is .asp or .asa, the server opens the file and scans for ASP tags (<% %>) that identify ASP code. The server then processes the code and places the results—as HTML code—back into the page.

Limit your use of cookies. You might use cookies to increase user convenience—for example, to store passwords, personal settings, and address information. But cookies are difficult to cache and can cause unusual page results—particularly if you use time-dependant applications or dynamic databases.

Be consistent in your use of the POST and GET methods for processing forms. Remember that POST places a form’s field values in the HTTP headers, whereas GET tacks this submitted information onto the URL. In most cases, the amount of POST data is too large to cache, whereas GET submissions are cacheable. On sites that use GET, when you use the Back button to go from a processed form to a previous form page, the previous page’s fields remain intact, thanks to caching and cookies. On sites that use POST, using the Back button requeries the server, and all data that you previously filled out is lost—a capability that you might or might not want. Additionally, GET can send only about 256 characters—a limitation that might influence your decision. If you don’t use a consistent approach to form processing, the system will cache some form results but won’t cache others.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish