Forum: Ruby on Rails cache_page does not work

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
shawn shao (Guest)
on 2007-06-01 13:11
(Received via mailing list)
Hi guys:
i got a problem on caching my pages:
in my Sweeper i wrote:
--------------------------------
class MySweeper < ActionController::Caching::Sweeper
  observe Post

  def after_save(post)
    expire_page(:controller => 'post', :action => 'show', :id =>
post.id)
    cache_page(:controller => 'post', :action => 'show', :id =>
post.id)
  end

end
----------------------------------------
The problem is 'cache_page' NOT work while the 'expire_page' works
fine:
when i open the url: /post/show/id , a cache page is created in public/
post/show/ folder.
then i edit the post, the cache page was cleared by the sweeper, but
it does not be created until i reopen the show page url in brower.
this problem occured in my controller too ...

any help idea? or i just misunderstand the 'cache_page' method?

thanks for help
-- shawn
Mikkel (Guest)
on 2007-06-01 14:25
shawn shao wrote:

> The problem is 'cache_page' NOT work while the 'expire_page' works
> fine:
> when i open the url: /post/show/id , a cache page is created in public/
> post/show/ folder.
> then i edit the post, the cache page was cleared by the sweeper, but
> it does not be created until i reopen the show page url in brower.
> this problem occured in my controller too ...
>
> any help idea? or i just misunderstand the 'cache_page' method?
>
> thanks for help
> -- shawn

The cache is only created when the acutla page is rendered again...

it works as intended...
Shawn S. (Guest)
on 2007-06-01 14:41
Mikkel wrote:
>
> The cache is only created when the acutla page is rendered again...
>
> it works as intended...

Thanks for reply, Mikkel~~

so is there any way i can generate a cache page without rendering the
url page,
Or can i 'pretend' rendering it after save() action in my controller?
Peter De Berdt (Guest)
on 2007-06-01 19:38
(Received via mailing list)
On 01 Jun 2007, at 12:41, Shawn Shao wrote:

> so is there any way i can generate a cache page without rendering the
> url page,
> Or can i 'pretend' rendering it after save() action in my controller?

Although I would advise against it, you could issue a "curl "+url_for
(...)+" > /dev/null" using ruby's system command to load the page.


Best regards

Peter De Berdt
This topic is locked and can not be replied to.