# Cache expiration with format not working as expected

**URL:** <https://www.ruby-forum.com/t/cache-expiration-with-format-not-working-as-expected/171799>\
**Category:** Rails\
**Created:** [July 9, 2009, 12:38pm UTC](https://www.ruby-forum.com/t/cache-expiration-with-format-not-working-as-expected/171799 "2009-07-09T12:38:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [July 9, 2009, 12:38pm UTC](https://www.ruby-forum.com/t/cache-expiration-with-format-not-working-as-expected/171799/1 "2009-07-09T12:38:14Z")

</div>

Hi all,

In my OrdersController, I have two actions completed and incomplete  
that respond\_to HTML and CSV.

Im also action caching these actions

…  
caches\_action :completed, :incomplete  
…  
def completed  
@orders = Order.completed  
respond\_to do |format|  
format.html  
format.csv {render :layout =\> false}  
end  
end

def incomplete  
@orders = Order.incomplete  
respond\_to do |format|  
format.html  
format.csv {render :layout =\> false}  
end  
end

Now the cached fragments when I go to the CSV urls are

views/localhost:3001/orders/completed.csv  
views/localhost:3001/orders/incomplete.csv

My sweepers have the following cache expiration commands  
…  
expire\_action :controller =\> :orders, :action =\> :completed, :format  
=\> :csv  
expire\_action :controller =\> :orders, :action =\> :incomplete, :format  
=\> :csv  
…

But the log says

Expired fragment : views/localhost:3001/completed.csv  
Expired fragment : views/localhost:3001/incomplete.csv

notice that it missed “/orders” in there? The cache therefore never  
expires for the CSV format output. It works fine for HTML though. Any  
idea what im doing wrong?
