Does anyone have any suggestions on how to create Conditional Get
requests in rails? I understand the basic philosophy of the concept,
I was just wondering if there was an easy way (a helper or plugin) to
automatically generate the proper http headers when checking on
whether a file has been updated on a server. Ideally, I would like to
generate a conditional get in an if statement, followed by the caching
algorithm if the conditional get returns the document.
When looking at the api for stale? and fresh_when, I see that these
methods are part of action controller. I would like to use this
methodology to determine if an rss feed should be updated or not. The
validation process all resides in the Feed model and a related module,
so when I try to use the stale? method, I get an undefined method
error. Would it be better to recreate the source code in my module,
or is this the first indication that what I am trying to do is going
about it the wrong way? I would very much like to keep the process in
a module, as I am using a template pattern to define several different
caching methods for experiments on speed and agility.
Any suggestions or advice you may have on this subject would be
greatly appreciated!
In short — you’re doing it in the wrong way. Caching should be handled
on the controller layer, unless you really need something advanced
(and I don’t think you need it). So rethink the way your app is
designed.
I want to be the RECIPIENT of either the “304 Not Modified” result, or
the document if it has been modified. If I am reading the
documentation properly, It is describing ways to handle a request and
return the message, so I am looking for the other end of the stick.
I have been successful at generating my desired results using open-
uri. Detailed information is available here: