# Page caching with custom routes

**URL:** <https://www.ruby-forum.com/t/page-caching-with-custom-routes/63342>\
**Category:** Rails\
**Created:** [June 14, 2006, 12:06pm UTC](https://www.ruby-forum.com/t/page-caching-with-custom-routes/63342 "2006-06-14T12:06:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 14, 2006, 12:06pm UTC](https://www.ruby-forum.com/t/page-caching-with-custom-routes/63342/1 "2006-06-14T12:06:47Z")

</div>

hi ,

I’m having problems with expire\_page with custom routes  
i’ll show some code

## blog\_controller

def clear\_cache\_rss\_artikels  
expire\_page url\_for(:controller =\> “xml”,:action =\> “rss\_artikels”)  
end

this is called when a new article is posted or edited or destroyed

## xml\_controller

class XmlController \< ApplicationController  
caches\_page :rss\_artikels

def rss\_artikels  
@articles = Article.find(:all)  
end

end

## routes.rb

map.rss “rss/blog/artikels”,:controller =\> “xml”,:action =\>  
“rss\_artikels”

when the rss feed is called , rails make a file in the public directory  
rss/blog/artikels.html

but i can’t expire the page ,i think something is wrong with  
clear\_cache\_rss\_artikels , the routes aren’t called at the moment when  
expired\_page is called or could somebody help me?

greetz

Klaas

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 9, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/page-caching-with-custom-routes/63342/2 "2006-07-09T19:06:23Z")

</div>

Hi Klaas

I don’t think you need to call the url\_for() method. Your expire  
method should look like:

def clear\_cache\_rss\_artikels  
expire\_page(:controller =\> “xml”,:action =\> “rss\_artikels”)  
end

Hope this helps,  
Simon
