Forum OpenACS Q&A: Re: adding header to resource files: cache-control max-age=NNNN

Dear Cesareo,

using expire for file in the content repository is much more problematic than for resources. When an end-user updates a file in the content-repository (say in file-storage, or wiki) then one expects that all user sees this change as well more or less immediately. With expires, people will see for a while the outdated files, which are served from local caches (unless they force a reload). Furthermore, the requirement of different applications of the content repository are different (e.g. photo-album, of different kind of file-storages). So having a single expire time for all usages of the file-storages is not advisable.

My case scenario is mainly with photo-album. So it would be a good idea to use a parameter per package.

I'll change it in my setup to use only inside photo-album. Thanks 😉

Just to keep documented here. I'm using it now in photo album to serve images (6 months cache)

diff --git a/packages/photo-album/www/images/index.vuh b/packages/photo-album/www/images/index.vuh
index ce37de7..2a567bd 100644
--- a/packages/photo-album/www/images/index.vuh
+++ b/packages/photo-album/www/images/index.vuh
@@ -18,6 +18,10 @@ if {[parameter::get -parameter CheckPermissionOnImageServeP] == "t"} {
permission::require_permission -object_id $image_id -privilege "read"
}

+# Based on http://www.openacs.org/forums/message-view?message_id=4231862
+# Six months expire
+ ns_setexpires [expr {60*60*24*30*6}]
+
if {[catch {cr_write_content -revision_id $image_id} errMsg]} {
if {$::errorCode eq "NOT_FOUND"} {
ns_returnnotfound