Lasso Soft Inc. > Home

[l9_header_nocache]

Linkl9_header_nocache
AuthorJonathan Guthrie
CategoryUtility
Version9.x
LicensePublic Domain
Posted12 Sep 2012
Updated12 Sep 2012
More by this author...

Description

The web has been built upon a foundation of static content, and in order to reduce bandwidth consumption and latency (i.e. increase perceived speed) an excellent mechanism for communicating caching options was devised.

However this is not really appropriate for today's dynamic web. It is often necessary to inform browsers specifically to not cache content in a forceful manner.

----

L9_header_nocache is a refinement of Bil Cory's lp_header_nocache, rewritten to address the web_response object directly in Lasso 9.

Add this method anywhere on your page and it will modify the headers sent to the browser telling it to treat the content as fresh content every time.

This does not affect images and other media served up as a result of the html or xhr - they have their own headers and caching.

Reference items used in this method:

http://www.lassosoft.com/LassoDocs/languageReference/obj/web_response/headers
http://www.lassosoft.com/lassoDocs/languageReference/obj/web_response/addHeader
http://www.lassosoft.com/LassoDocs/languageReference/obj/web_response/replaceHeader

 

Sample Usage

l9_header_nocache

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define l9_header_nocache() => {
	/* ===============================================================
		A refinement/rework of Bil Cory's lp_header_nocache
		This works natively with Lasso 9's web_response object
	=============================================================== */
	web_response->headers >> 'Expires' ? web_response->replaceHeader('Expires' = '-1') | web_response->addHeader('Expires' = '-1')
	local(reval = 'no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0')
	web_response->headers >> 'Cache-Control' ? web_response->replaceHeader('Cache-Control' = #reval) | web_response->addHeader('Cache-Control' = #reval)
	web_response->headers >> 'Pragma' ? web_response->replaceHeader('Pragma' = 'no-cache') | web_response->addHeader('Pragma' = 'no-cache')
	web_response->headers >> 'vary' ? web_response->replaceHeader('vary' = '*') | web_response->addHeader('vary' = '*')
	web_response->headers >> 'ETag' ? web_response->replaceHeader('ETag' = Lasso_UniqueID) | web_response->addHeader('ETag' = Lasso_UniqueID)
}

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft