It should work.  Just be careful not to customize the page with
some specific login information, the cached version will be shared by
all users.

     /AITOR

On 9/25/07, Chris Dwan <[EMAIL PROTECTED]> wrote:
> I'm working on a site that will have a membership area that will
> require login. I'm a sucker for caching, and all the solutions I've
> seen so far disable the cache to get auth working.  I haven't dug in
> deep into this idea yet, but I'm pondering the value of tweaking
> ResponseCache to store something like an auth_required value in the
> YML file and returning auth_required pages from the cache only if a
> user is logged-in.  That way logged-in users get the benefit of
> cached pages.
>
> Non-logged-in folks won't get the cached page, so they'll have the
> page dynamically loaded and get caught by the 'hey-you-log-in-first'
> routine.
>
> Are there any major reasons against the idea?
>
> basically, it would look like this...
>
>
> ## there will be a before_filter on SiteController to establish the
> value of logged_in
>
>   def read_metadata(path, logged_in)
> #added a parameter
>      path = clean(path)
>      name = "#{page_cache_path(path)}.yml"
>      if File.exists?(name) and not File.directory?(name)
>        content = File.open(name,"rb") { |f| f.read }
>        metadata = YAML::load(content)
>        auth_required = metadata['auth_required']             #added
>        if(metadata['expires'] && metadata['expires'] >= Time.now && (!
> auth_required || (auth_required && logged_in))  #updated
>          return metadata
>        end
>      end
>    end
>
>    def response_cached?(path, logged_in = false)        #added a
> parameter
>      !!read_metadata(path, logged_in)
> #here too
>    end
>
>
>
>
> _______________________________________________
> Radiant mailing list
> Post:   [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to