lib/nitro/caching/output.rb in nitro-0.29.0 vs lib/nitro/caching/output.rb in nitro-0.30.0
- old
+ new
@@ -9,11 +9,12 @@
# The Output caching subsystem stores whole pages in the
# filesystem to be served directly be the front web server
# (Lighttpd, Apache, etc) for optimal performance.
#
# Nitro promotes coding your application in such a way as to
- # allow for output caching to the greatest extend.
+ # allow for output caching to the greatest extend. Output
+ # caching *is your friend*.
#--
# gmosx, FIXME: Don't create excessive directories, use better
# rewrite rules to handle xxx.html files.
#++
@@ -64,23 +65,32 @@
if caching_enabled? and caching_allowed?
self.class.do_cache_output(@request.uri, @out)
end
end
+ # Explicitly expire the output cached under the given
+ # cache key. The cache key is typically the name of the
+ # top level action responsible for generating the page.
#--
# If you change this method, don't forget the CacheSweeper
# expire method.
#++
def expire_output(name)
begin
- Logger.debug "Expirinig cache file '#{context.dispatcher.public_root}/#{name}'" if $DBG
- FileUtils.rm_rf("#{context.dispatcher.public_root}/#{name}")
- rescue Object
+ Logger.debug "Expirinig cache file '#{Server.public_root}/#{name}'" if $DBG
+ FileUtils.rm_rf("#{Server.public_root}/#{name}")
+ rescue Object => ex
# gmosx: is this the right thing to do?
end
end
alias_method :delete_output, :expire_output
+
+ # Is caching allowed for this action (page)? The default
+ # implementation does not cache post request or request
+ # with query parameters. You can work arround the second
+ # 'limitation' by cleverly using Nitro's implicit support
+ # for 'nice' urls.
def caching_allowed?
not (@request.post? or @request.uri =~ /\?/)
end