Created
September 30, 2008 20:32
-
-
Save kelp/13939 to your computer and use it in GitHub Desktop.
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
# Last modified 2008/09/30 01:30PM - kelp | |
# If the http response code is 404 or 500 don't allow caching and | |
# exit the script. | |
$rawurl = http.getRawURL(); | |
$code = http.getResponseCode(); | |
if ( $code == 404 || $code == 500 ) { | |
http.setResponseHeader( "Pragma", "no-cache" ); | |
http.removeResponseHeader( "Expires" ); | |
http.setResponseHeader( "Cache-Control", "public, max-age=0" ); | |
http.setResponseHeader( "Expires", sys.gmtime.format( "%a, %d %b %Y %T GMT" ) ); | |
break; | |
} | |
# The rpc and framework swfs can be cached for 20 years. | |
$path = http.getpath(); | |
if ( string.regexmatch( $path, "^\\/swfs\\/(framework|rpc)_.*\\.sw." ) ) { | |
http.removeResponseHeader( "Expires" ); | |
if( http.getResponseHeader( "Pragma" ) == "no-cache" ){ | |
http.removeResponseHeader( "Pragma" ); | |
} | |
http.setResponseHeader( "Cache-Control", "public, max-age=631138519" ); | |
$expires=sys.gmtime.format( "%a, %d %b %Y %T GMT", sys.time() + 631138519 ); | |
http.setResponseHeader( "Expires", $expires ); | |
# log.info("RPC & Framework" . $path); | |
# Anything else in the /swfs/ directory is cached for 1 day. | |
} else if( string.startswith( $path, "/swfs/" ) ){ | |
http.removeResponseHeader( "Expires" ); | |
if( http.getResponseHeader( "Pragma" ) == "no-cache" ){ | |
http.removeResponseHeader( "Pragma" ); | |
} | |
http.setResponseHeader( "Cache-Control", "public, max-age=86400" ); | |
$expires=sys.gmtime.format( "%a, %d %b %Y %T GMT", sys.time() + 86400 ); | |
http.setResponseHeader( "Expires", $expires ); | |
# log.info("Other SWFS" . $path); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment