Fork me on GitHub

cache 1.0.190

node:

Text

THE
html()
FUNCTION
mixer
cache 1.0.190
category
Cache
{
Overview

An overload of the html function that does the cache stuff as well.

This html function sets up the page so that content you label dynamic is fetched as needed, but still allows the static section of the page to be cached. The following example will open an html scope and set up the page so that all divs with the "dynamic" attribute are stripped out and will be loaded later. If no encoding is specified, it will attempt to automatically detect the encoding, just like the standard html function.

*
This function has no arguments
Example
cache.html() {
  $("//div[@dynamic]") {
    cache.dynamic_section()
  }
}
»
View Source
node:

Text

THE
html(Text %enc)
FUNCTION
mixer
cache 1.0.190
category
Cache
{
Overview

An overload of the html function that does the cache stuff as well.

This html function sets up the page so that content you label dynamic is fetched as needed, but still allows the static section of the page to be cached. The following example will open an html scope and set up the page so that all divs with the "dynamic" attribute are stripped out and will be loaded later. If no encoding is specified, it will attempt to automatically detect the encoding, just like the standard html function.

*
Argument
Type
Name
Text %enc
Example
cache.html("utf-8") {
  $("//div[@dynamic]") {
    cache.dynamic_section()
  }
}
»
View Source
node:

Text

THE
dynamic_section()
FUNCTION
mixer
cache 1.0.190
category
Cache
{
Overview

This function goes hand-in-hand with the cache.html function to allow dynamic sections to be flagged and loaded later.

Use this function to specify dynamic content that should not be cached. The following example will open an html scope and set up the page so that all divs with the "dynamic" attribute are stripped out and will be loaded later.

*
This function has no arguments
Example
cache.html("utf-8") {
  $("//div[@dynamic]") {
    cache.dynamic_section()
  }
}
»
View Source
node:

Base

THE
enable()
FUNCTION
mixer
cache 1.0.190
category
Cache
{
Overview

Enables the caching header for the page.

This function will set the cache header of your page to true with no additional parameters

*
This function has no arguments
Example
cache.enable()
/*
Example outgoing response headers. Notice the additional X-Moov-Cache and Cache-Control headers

HTTP/1.1 200 OK
Date: Tue, 22 Oct 2013 23:46:42 GMT
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
Content-Length: 23102
Cache-Control: public, max-age=60
X-Moov-Cache: true
X-Q-S: 200003309002110001182
X-M-V: 4.8.24
X-S-V: local/myproject 
*/
»
View Source
node:

Base

mixer
cache 1.0.190
category
Cache
{
Overview

Enables caching of things for a specified period of time.

This function will set the necessary headers to tell Moovweb to cache the current response. The parameter is the number of seconds to cache things for. The following example will cache the stuff on the page for 1 minute.

*
Argument
Type
Name
Text %seconds
Example
cache.enable_for("60") # set the cache headers for 60 seconds
»
View Source
node:

Base

THE
force()
FUNCTION
mixer
cache 1.0.190
category
Cache
{
Overview

Adds a forced caching header to the page.

This function will set the cache control header to a non-zero TTL. The cache headers will be set regardless of the upstream response's cache headers (even if its set to max-age 0 for example).

*
This function has no arguments
Example
cache.force()
/*
Example outgoing response headers. Notice the additional X-Moov-Cache and Cache-Control headers.

HTTP/1.1 200 OK
Date: Tue, 22 Oct 2013 23:46:42 GMT
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
Content-Length: 23102
Cache-Control: public, max-age=60
X-Moov-Cache: true
X-Q-S: 200003309002110001182
X-M-V: 4.8.24
X-S-V: local/myproject 
*/
»
View Source
node:

Base

mixer
cache 1.0.190
category
Cache
{
Overview

Forces caching of things for a specified period of time in Moovweb's cache only.

This function will set the necessary headers to tell Moovweb to cache the current response and strip other caching headers out. The parameter is the number of seconds to cache things for. The following example will cache the stuff on the page for 1 minute.

*
Argument
Type
Name
Text %seconds
Example
cache.force_for("60") # remove other cache headers and set ours for 60 seconds
»
View Source