cache 1.0.149
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.
cache.html("utf-8") { $("//div[@dynamic]") { cache.dynamic_section() } }
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.
cache.html("utf-8") { $("//div[@dynamic]") { cache.dynamic_section() } }
Enables the caching header for the page.
This function will set the cache header of your page to true
with no additional parameters
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 */
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.
cache.enable_for("60") # set the cache headers for 60 seconds
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).
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 */
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.
cache.force_for("60") # remove other cache headers and set ours for 60 seconds