ad_http_cache_control (private)
ad_http_cache_control
Defined in packages/acs-tcl/tcl/request-processor-procs.tcl
This adds specific headers to the http output headers for the current request in order to prevent user agents and proxies from caching the page.
It should be called only when the method to return the data to the client is going to be ns_return. In other cases, e.g. ns_returnfile, one can assume that the returned content is not dynamic and can in fact be cached. Besides that, AOLserver implements its own handling of Last-Modified headers with ns_returnfile. Also it should be called as late as possible - shortly before ns_return, so that other code has the chance to set no_cache_control_p to 1 before it runs.
This proc can be disabled per request by calling "ad_conn -set no_http_cache_control_p 1" before this proc is reached. It will not modify any headers if this variable is set to 1.
If the acs-kernel parameter CacheControlP is set to 0 then it's fully disabled.
- Author:
- Tilmann Singer <tils-oacs@tils.net>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if { ![parameter::get -package_id $::acs::kernel_id -parameter HttpCacheControlP -default 0]} { return } if { [info exists ::ad_conn(no_http_cache_control_p)] && $::ad_conn(no_http_cache_control_p) } { return } set headers [ad_conn outputheaders] # Check if any relevant header is already present - in this case # don't touch anything. if { [ns_set ifind $headers "cache-control"] > -1 || [ns_set ifind $headers "expires"] > -1 || [string tolower [ns_set iget $headers "pragma"]] eq "no-cache" } { set modify_p 0 } else { set modify_p 1 } # Set three headers, to be sure it won't get cached. If you are in # doubt, check the spec: # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html if { $modify_p } { # actually add the headers ns_setexpires 0 ns_set put $headers "Pragma" "no-cache" ns_set put $headers "Cache-Control" "no-cache" } # Prevent subsequent calls of this proc from adding the same # headers again. ad_conn -set no_http_cache_control_p 1XQL Not present: Generic, PostgreSQL, Oracle