Documentation You are here: start » v » 0.6.0 » docs » automagicache

Template Caching

We affectionately refer to our template caching system as “AutoMagiCache”. It's a whole mess of very exciting regular expressions that will automatically pull in a page from your server, rewrite and cache your paths and images, and store it on our server.

What It Does

  1. Pulls in target URL.
  2. Strips any <base> tags.
  3. “Convenience replacements”, currently converting “http” to “https” links for:
    • Google Analytics
  4. Imports non-secure external CSS
    • Rewrites all image paths (*.jpg, *.jpeg, *.png, *.gif) to use FoxyCart image caching.
    • Sticks it inline, inside CDATA comments.
  5. Imports non-secure external JS
    • Replaces / / with \/\/ when not preceded by a space or line break.
    • Replaces all </ with <\/.
    • Sticks it inline, inside CDATA comments.
  6. Rewrites all <img> paths to use FoxyCart image caching.
  7. Rewrites all <a> paths to point to the correct locations.
  8. Rewrites all <form> actions to point to correct locations.

What Is Supported?

  • Most everything not listed below.

Important Notes

  • Preventing Hotlinking? If you're running scripts to prevent hotlinking, that may interfere with the template caching. If images aren't showing up properly, turn off your hotlinking protection while you cache your templates.
  • Attributes must be enclosed in single or double quotes like src=“foo/bar” or src='foo/bar'.
  • Your page must have a UTF-8 content type so you may need to add this inside your document's head tag: <meta http-equiv=“Content-Type” content=“text/html; charset=utf-8”/>.
  • Flash will not be cached. Because it's near-impossible to “see inside” of a swf file, there's no good way to ensure that additional necessary files (like xml, flv, etc.) are cached along with the swf file itself.
  • “Upward relative paths” (stuff like ../foo/bar.ext) more than one level deep are not supported. ../foo/bar.ext will work, but ../../foo/bar.ext will not. If you have a legitimate need for more than one level deep, let us know.
  • @IMPORT rules more than one level deep are not supported. An import will work just fine, but an import inside an import won't be cached. If you have a legitimate need for more than one level deep, let us know.
  • jQuery must be v1.1.2+ or it will conflict with internal FoxyCart functionality.
  • HTC files. These may work if you're using a custom subdomain, but likely will not work if you're using a default *.foxycart.com subdomain.

Comments, Conditional Comments, and the Ampersand ("&")

For some reason, Firefox and Internet Explorer create problems when you have the ampersand (”&”) character inside of code comments:

<!--
Some text & more
-->

If you rely on conditional comments for Internet Explorer, and inside of those conditional comments you have ampersands, you'll need to use a very specific syntax to include your comments, detailed at Wellstyled.com. The important piece to notice is the <!–>, which needs to be included or you'll run into problems with the & being replaced by &amp; every time you save your template. We're still figuring this out.

Placeholders in your CSS or JS

The following placeholders will be replaced with “spaced” placeholders in cached CSS and JS, to prevent problems with parsing placeholders that shouldn't be parsed.

  • ^^cart^^^^ cart ^^
  • ^^checkout^^^^ checkout ^^
  • ^^receipt^^^^ receipt ^^
  • ^^analytics_google^^^^ analytics_google ^^

Caching Images Manually

If you don't want to use AutoMagiCache but still need your images securely cached you can do so. View the instructions here.

Site Tools