Revisiting the caching idea below - would in httpd.conf

MasonPreloads  index.mhtml

be more appropriate if I have an index.mhtml that I want to load as fast
as possible? Note that I have a form on this page which has several sql
calls to generate and if the user clicks back on it after filling out
the form it will preload those values as the values in the form.

TIA

Justin




On Thu, 2005-12-08 at 17:03 -0500, Jeremy Blain wrote:
> You'll have to do something other than cache self.
> Something like (totally untested, and a little sloppy):
> 
> <%init>
> unless ($m->session->{seen_homepage}) {
>      my $content = $m->cache->get('homepage');
>      if ($content) {
>          $m->session->{seen_homepage} = 1;
>          $m->print($content);
>          return;
>      }
>     elsif ($m->call_self(\$content)) {
>          $m->cache->set('homepage',$content, '24 hours');
>          $m->session->{seen_homepage} = 1;
>          $m->print($content);
>     }
>     return;  
> }
> # if we get down to here, generate either a custom, or default
> # homepage depending on if {seen_homepage} is set.
> <%/init>
> 
> Justin Cook wrote:
> 
> >I'm been playing around with $m->cache_self() and would like to use it
> >to cache my site's homepage to speed up loading for each new visitor.
> >What I would like to see is my homepage cached after the first initial
> >rendering and then served to each new unique visitor. 
> >So I added:
> >
> ><snip>
> ><%init>
> >return if $m->cache_self;
> ></%init>
> ></snip>
> >
> >to index.html and what I'm seeing in my limited time using it is it
> >creates an object file
> >- /var/site/cache/index.html/e/5/4/e540cdd1328b2b21e29a95405c301b9313b7c322 
> >which seems to be based on the session ID assigned by 
> >MasonX::Request::WithApacheSession. Now I assume this cached page will only 
> >be used if this same session user hit my homepage, and will create a new 
> >cached page for each new user request. This is not what I want.
> >
> >I've tried using the cache_self(key => 'foo') but that doesn't seem to
> >achieve the desired result. There is a form on this page that is
> >pre-filled if the user had already filled it up, but otherwise new
> >visitors should all see the same thing. It also has pre-filled dates, so
> >it would have to be purged and re-cached on midnight of everyday.
> >
> >Is this senario that cache_self is made for? I feel like I'm missing out
> >on using "one of Mason's greatest features";).
> >
> >Justin
> >
> >
> >
> >-------------------------------------------------------
> >This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> >for problems?  Stop!  Download the new AJAX search engine that makes
> >searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> >http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> >_______________________________________________
> >Mason-users mailing list
> >[email protected]
> >https://lists.sourceforge.net/lists/listinfo/mason-users
> >  
> >
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Mason-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mason-users



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to