Created
September 7, 2011 19:42
-
-
Save justis/1201513 to your computer and use it in GitHub Desktop.
no client caching for www/resources on development systems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ad_proc -private rp_resources_filter { why } { | |
This filter runs on all URLs of the form /resources/*. The acs-resources package | |
mounts itself at /resources but we short circuit references here in order to | |
maximize throughput for resource files. We just ns_returnfile the file, no | |
permissions are checked, the ad_conn structure is not initialized, etc. | |
There are two mapping possibilities: | |
/resources/package-key/* maps to root/packages/package-key/www/resources/* | |
If that fails, we map to root/www/resources/* | |
If the file doesn't exist we'll log an error and return filter_ok, which will allow | |
packages mounted at "/resources" in a legacy site to work correctly. This is a | |
horrible kludge which may disappear after discussion with the gang. | |
@author Don Baccus (dhogaza@pacifier.com) | |
} { | |
set path "[acs_package_root_dir [lindex [ns_conn urlv] 1]]/www/resources/[join [lrange [ns_conn urlv] 2 end] /]" | |
if { ![file isfile $path] } { | |
set path "[acs_root_dir]/www/resources/[join [lrange [ns_conn urlv] 1 end] /]" | |
} | |
if { [file isfile $path] } { | |
# TODO make this vary between dev and prod | |
set headers [ns_conn outputheaders] | |
if { 1 } { | |
ns_setexpires 0 | |
ns_set put $headers "Pragma" "no-cache" | |
ns_set put $headers "Cache-Control" "no-cache" | |
} | |
ns_returnfile 200 [ns_guesstype $path] $path | |
return filter_return | |
} else { | |
ns_log Error "rp_sources_filter: file \"$path\" does not exists trying to serve as a normal request" | |
return filter_ok | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment