# Expiring page caches with regexp?

**URL:** <https://www.ruby-forum.com/t/expiring-page-caches-with-regexp/120925>\
**Category:** Rails\
**Created:** [November 21, 2007, 8:27pm UTC](https://www.ruby-forum.com/t/expiring-page-caches-with-regexp/120925 "2007-11-21T20:27:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![idlefingers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/898d66/32.png) [@idlefingers](https://www.ruby-forum.com/u/idlefingers)\
**Post date:** [November 21, 2007, 8:27pm UTC](https://www.ruby-forum.com/t/expiring-page-caches-with-regexp/120925/1 "2007-11-21T20:27:27Z")

</div>

Is there a way to expire page caches using regular expressions like  
you can with fragment caches?

I’m writing an app which has a catalogue style product listing but not  
full on e-commerce. It’s pretty simple; with just categories and  
products within them. A url for a product called “Band Saws” within  
the category “Heavy duty saws” would look like “[http://domain.com/](http://domain.com/)  
products/heavy-duty-saws/band-saws”.

The problem is that when an admin user edits a category (“Heavy duty  
saws”), I need to expire the entire “heavy-duty-saws” directory in  
public to wipe every product which has been cached within that  
category. With fragment caching, I’d just use regexp, but that doesn’t  
seem to work in page caching (at least the same way it does with  
fragments).

I tried using "system “rm -rf #{RAILS\_ROOT}/public/products/  
#{category.url\_slug}” from within the CategorySweeper which I was  
trying to get the expire\_page method to work in but it didn’t work  
either (I didn’t really dig far into why this one wasn’t working…  
should it?)

Thanks in advance for any help.
