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

The head version of OpenACS has now a package parameter for kernel named ResourcesExpireInterval for specifying the expiration interval for /resources/*. Per default, no expiration interval is set.
Excellent! Thank you, Gustaf.
Related with this but with Content Repository. I was looking to specify Expires: header to images (photo-album) and modify
/packages/acs-content-repository/tcl/revision-procs.tcl [See below]. Please take in mind that perhpas this is not the best solution.

Would it a good idea to add a ResourcesExpiralInterval to Content Repository Parameters?

index 88c68b7..6a690ab 100644
--- a/packages/acs-content-repository/tcl/revision-procs.tcl
+++ b/packages/acs-content-repository/tcl/revision-procs.tcl
@@ -57,6 +57,10 @@ ad_proc -public cr_write_content {
set content_length 0

+# Based on
+ ns_setexpires [expr {60*60*24*30}]
+ns_log warning "Setting Expires en $storage_type $revision_id"
switch $storage_type {
text {
set text [db_string write_text_content ""]

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
+# 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"} {