# Cache Home Page (prevent the long delay)

**URL:** <https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373>\
**Category:** Radiant CMS\
**Created:** [January 22, 2009, 4:50pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373 "2009-01-22T16:50:12Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 4:50pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/1 "2009-01-22T16:50:12Z")

</div>

I run Radiant on Passenger and I was wondering if there was a way to  
have the home page of a site always cached.

When there have been no visitors to a site for about a day, it often  
takes the sever more than 20 seconds to respond to a request for a page.

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 4:57pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/2 "2009-01-22T16:57:26Z")

</div>

Ben M. wrote:

> I run Radiant on Passenger and I was wondering if there was a way to  
> have the home page of a site always cached.
> 
> When there have been no visitors to a site for about a day, it often  
> takes the sever more than 20 seconds to respond to a request for a page.

I think that is probably when it recreates the whole page and loads  
Rails, etc. Does the home page change a lot? If it doesn’t change,  
would it make sense to create a static version of it?

I believe that there is a way to change the caching settings, but sorry  
I don’t have that available off-hand.

There are these items stored in my email folder:

- [GitHub - bellroy/radiant-static-caching-extension: (unsupported) Beta: Monkeypatch caching to write #{path}.html files so url rewrites can be used to serve cached content](http://github.com/tricycle/radiant-static-caching-extension)
- [Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/radiant-cache-extension/)
- [http://www.mokisystems.com/blog/fragment-caching-with-radiant-cms/](http://www.mokisystems.com/blog/fragment-caching-with-radiant-cms/)

Cheers,  
Mohit.  
1/22/2009 | 11:52 PM.

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 4:58pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/3 "2009-01-22T16:58:37Z")

</div>

On Jan 22, 2009, at 10:50 AM, Ben M. wrote:

> I run Radiant on Passenger and I was wondering if there was a way to  
> have the home page of a site always cached.
> 
> When there have been no visitors to a site for about a day, it often  
> takes the sever more than 20 seconds to respond to a request for a  
> page.

You could set the cache timeout to 2.days, or something of that nature.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/4 "2009-01-22T17:02:45Z")

</div>

You could fetch your homepage in a regular intervall via a cronjob.

E.g. wget -r -nd --delete-after [http://yoursite.com](http://yoursite.com)

/simon

On Thu, 22 Jan 2009 16:50:12 +0100

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 5:18pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/5 "2009-01-22T17:18:38Z")

</div>

To force Passenger to stay running, you can set PassengerPoolIdleTime to  
some insanely huge value. They recommend 2 x TimeBetweenRequests. So  
if it’s a day between requests, set the value to 2 \* 24 \* 60 \* 60 or  
172800.

Sean

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 8:23pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/6 "2009-01-22T20:23:34Z")

</div>

I haven’t tried it out yet with 0.7 yet at all. Are you using  
passenger to test or mongrel. In the past I have had problems with  
uploading and passenger in the development environment, but hitting  
submit again uploads it when it hangs. This does not happen in  
production and has been noted on the Paperclip mailing list.

Hope that helps a bit.

Keith

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 8:19pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/7 "2009-01-22T20:19:25Z")

</div>

I was wondering if anyone is using paperclipped with 0.7.0rc2. It  
seems to be stalling out on uploading an asset. This could easily be  
something unrelated to 0.7.0rc2. If anyone knows anything about  
what’s going on I’d greatly appreciate the help.

Steven

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 8:40pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/8 "2009-01-22T20:40:03Z")

</div>

On Jan 22, 2009, at 11:18 AM, Steven S. wrote:

> I was wondering if anyone is using paperclipped with 0.7.0rc2. It  
> seems to be stalling out on uploading an asset. This could easily  
> be something unrelated to 0.7.0rc2. If anyone knows anything about  
> what’s going on I’d greatly appreciate the help.

Would the asset happen to be a non-image file like a PDF or Word  
document? I couldn’t get past this problem, hence I went with  
page\_attachments, but others on this list have gotten it working.

Jose

…  
Jose Hales-Garcia  
UCLA Department of Statistics  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 8:50pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/9 "2009-01-22T20:50:37Z")

</div>

Well I’m using mongrel in a production environment. It was hanging  
when I upload an image but I shut down a few processes and it seems to  
be going through. Now when I try to remove an asset I get an  
Application error. If i hit refresh three or four time it does clear  
itself up and remove the asset. I’m also using Setting so I wonder if  
there could be a problem with that.

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 23, 2009, 7:42pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/10 "2009-01-23T19:42:07Z")

</div>

On Thu, Jan 22, 2009 at 6:53 PM, Benny D.  
\<removed\_email\_address@domain.invalid

> wrote:

> named route that no longer exists.
> 
> > 
> 
> I also made it skip mimetype validation altogether if you set  
> Radiant::Config[“assets.skip\_filetype\_validation”] = true
> 
> see the github network;  
> [Network Graph · kbingman/paperclipped · GitHub](http://github.com/kbingman/paperclipped/network)

That is great information, Benny. When I move up to 0.7, I’ll definitely  
need this. Thanks.

~Nate

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 22, 2009, 9:10pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/11 "2009-01-22T21:10:01Z")

</div>

On Thu, Jan 22, 2009 at 1:39 PM, Jose Hales-Garcia  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> I couldn’t get past this problem, hence I went with page\_attachments, but  
> others on this list have gotten it working.

It works with other mime-types, but you have to specify them using the  
Settings extension. You may also need to pare (sp?) down the number of  
mime-types listed as well, because sometimes that field in settings is  
truncated. It’s really no big deal, just take out the mime-types you’ll  
never use (and there are a few) and replace them with the ones you need.

I have no problems using paperclipped, but I am using it with 0.6.9,  
though.

~Nate

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 23, 2009, 10:58pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/12 "2009-01-23T22:58:15Z")

</div>

Sean C. wrote:

> To force Passenger to stay running, you can set PassengerPoolIdleTime to  
> some insanely huge value. They recommend 2 x TimeBetweenRequests. So  
> if it’s a day between requests, set the value to 2 \* 24 \* 60 \* 60 or  
> 172800.

Thanks for all the suggestions!

I decided to go with a cron job so that I wouldn’t have to guess about  
what to change the cache or server settings to.

However, it wasn’t working properly – still had the long delay – while  
I was using “\> /dev/null” for some reason. So I simply removed that part  
and stuck with the “-s” flag, and now the page loads up immediately.

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 29, 2009, 1:09pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/13 "2009-01-29T13:09:35Z")

</div>

Sounds like paperclip should use FileUtils.rm\_rf instead of rm\_dir.

Sean

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 29, 2009, 12:47pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/14 "2009-01-29T12:47:19Z")

</div>

Steven,

Thanks for the detailed stacktrace. This is interesting, it really  
sounds like a difference between Solaris and the Mac. If I have a  
minute today I’ll look at the paperclipped source and see if I can  
figure out what’s going on. It’s acting like the extension is trying  
to delete the directory before all the files have been removed. Maybe  
Solaris throws an EEXIST when an rmdir is attempted on a non-empty  
directory but Linux/Mac throws something else, or nothing.

Unfortunately I don’t have access to a Solaris machine to test on.

Solaris has a reputation for being “different”–most of the Mac and  
Linux command line tools and libraries are pretty similar, but the  
Solaris libraries have been their own forever. The first thing I  
would do when encountering a Solaris box that I was responsible for  
was to install most of the Gnu suite.

–cro

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 29, 2009, 1:09pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/15 "2009-01-29T13:09:40Z")

</div>

Steven,

Also, can you send us a server log excerpt for this delete?

–cro

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 29, 2009, 1:09pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/16 "2009-01-29T13:09:43Z")

</div>

On Jan 28, 2009, at 11:49 AM, Sean C. wrote:

> Sounds like paperclip should use FileUtils.rm\_rf instead of rm\_dir.

It doesn’t, at least if it is the same as the one I have installed.  
Here’s the code:

```
   def flush_deletes #:nodoc:
     logger.info("[paperclip] Deleting files for #{name}")
     @queued_for_delete.each do |path|
       begin
         logger.info("[paperclip] -> #{path}")
         FileUtils.rm(path) if File.exist?(path)
       rescue Errno::ENOENT => e
         # ignore file-not-found, let everything else pass
       end
     end
     @queued_for_delete = []
   end
 end

```

File.exist? returns true for files and directories. But unless I have  
an old version of paperclipped that doesn’t call FileUtils.rm, the  
Ruby docs say specifically that FileUtils.rm does not remove  
directories. And to be really safe, it should use  
FileUtils.remove\_entry\_secure.

Steven, you might try a quick patch and change FileUtils.rm to  
FileUtils.remove\_entry\_secure (or FileUtils.rm\_rf like Sean suggests  
if you are not terribly worried about security) in vendor/extensions/  
paperclipped/vendor/plugins/paperclip/lib/paperclip/storage.rb

–cro

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 29, 2009, 1:56pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/17 "2009-01-29T13:56:36Z")

</div>

Thank you for looking into this. I tried both yours and Sean quick fix  
and neither helped.

here is the full stack

Parameters: {“action”=\>“remove”,  
“authenticity\_token”=\>“b3c11c1f1191103da344cae2345c5beb9a7654d”,  
“id”=\>“11”, “controller”=\>“assets”}  
[paperclip] Paperclip attachment asset on Asset initialized.  
[paperclip] Deleting attachments.  
[paperclip] Queueing the existing files for asset for deletion.  
[paperclip] Deleting files for asset  
[paperclip] -\> /users/home/…/web/public/assets/11/testimage.jpg

Errno::EEXIST (File exists - /users/home/…/web/public/assets/11):  
/usr/local/lib/ruby/1.8/fileutils.rb:264:in `rmdir' /usr/local/lib/ruby/1.8/fileutils.rb:264:in`rmdir’  
/usr/local/lib/ruby/1.8/fileutils.rb:263:in `each' /usr/local/lib/ruby/1.8/fileutils.rb:263:in`rmdir’  
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/  
paperclip/storage.rb:62:in `flush_deletes' /vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/ paperclip/storage.rb:52:in`each’  
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/  
paperclip/storage.rb:52:in `flush_deletes' /vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/ paperclip.rb:301:in`send’  
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/  
paperclip.rb:301:in `destroy_attached_files' /vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/ paperclip.rb:286:in`each\_attachment’  
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/  
paperclip.rb:285:in `each' /vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/ paperclip.rb:285:in`each\_attachment’  
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/  
paperclip.rb:299:in `destroy_attached_files' /vendor/rails/activerecord/lib/../../activesupport/lib/ active_support/callbacks.rb:173:in`send’  
/vendor/rails/activerecord/lib/…/…/activesupport/lib/  
active\_support/callbacks.rb:173:in `evaluate_method' /vendor/rails/activerecord/lib/../../activesupport/lib/ active_support/callbacks.rb:161:in`call’  
/vendor/rails/activerecord/lib/…/…/activesupport/lib/  
active\_support/callbacks.rb:93:in `run' /vendor/rails/activerecord/lib/../../activesupport/lib/ active_support/callbacks.rb:92:in`each’  
/vendor/rails/activerecord/lib/…/…/activesupport/lib/  
active\_support/callbacks.rb:92:in `send' /vendor/rails/activerecord/lib/../../activesupport/lib/ active_support/callbacks.rb:92:in`run’  
/vendor/rails/activerecord/lib/…/…/activesupport/lib/  
active\_support/callbacks.rb:272:in `run_callbacks' /vendor/rails/activerecord/lib/active_record/callbacks.rb:298:in`callback’  
/vendor/rails/activerecord/lib/active\_record/callbacks.rb:288:in  
`destroy_without_transactions' /vendor/rails/activerecord/lib/active_record/transactions.rb: 102:in`destroy’  
/vendor/rails/activerecord/lib/active\_record/connection\_adapters/  
abstract/database\_statements.rb:66:in `transaction' /vendor/rails/activerecord/lib/active_record/transactions.rb: 79:in`transaction’  
/vendor/rails/activerecord/lib/active\_record/transactions.rb:  
98:in `transaction' /vendor/rails/activerecord/lib/active_record/transactions.rb: 102:in`destroy’  
/vendor/extensions/paperclipped/app/controllers/  
assets\_controller.rb:110:in `remove' /vendor/rails/actionpack/lib/action_controller/base.rb:1166:in`send’  
/vendor/rails/actionpack/lib/action\_controller/base.rb:1166:in  
`perform_action_without_filters' /vendor/rails/actionpack/lib/action_controller/filters.rb:579:in`call\_filters’  
/vendor/rails/actionpack/lib/action\_controller/filters.rb:572:in  
`perform_action_without_benchmark' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb: 68:in`perform\_action\_without\_rescue’  
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb: 68:in`perform\_action\_without\_rescue’  
/vendor/rails/actionpack/lib/action\_controller/rescue.rb:201:in  
`perform_action_without_caching' /vendor/rails/actionpack/lib/action_controller/caching/ sql_cache.rb:13:in`perform\_action’  
/vendor/rails/activerecord/lib/active\_record/connection\_adapters/  
abstract/query\_cache.rb:33:in `cache' /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in`cache’  
/vendor/rails/actionpack/lib/action\_controller/caching/  
sql\_cache.rb:12:in `perform_action' /vendor/rails/actionpack/lib/action_controller/base.rb:529:in`send’  
/vendor/rails/actionpack/lib/action\_controller/base.rb:529:in  
`process_without_filters' /vendor/rails/actionpack/lib/action_controller/filters.rb:568:in`process\_without\_session\_management\_support’  
/vendor/rails/actionpack/lib/action\_controller/  
session\_management.rb:130:in `sass_old_process' /vendor/plugins/haml/lib/sass/plugin/rails.rb:19:in`process’  
/vendor/rails/actionpack/lib/action\_controller/base.rb:389:in  
`process' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb: 149:in`handle\_request’  
/vendor/rails/actionpack/lib/action\_controller/dispatcher.rb:  
107:in `dispatch' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb: 104:in`synchronize’  
/vendor/rails/actionpack/lib/action\_controller/dispatcher.rb:  
104:in `dispatch' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb: 120:in`dispatch\_cgi’  
/vendor/rails/actionpack/lib/action\_controller/dispatcher.rb:  
35:in `dispatch' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel/rails.rb:76:in`process’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/  
mongrel/rails.rb:74:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel/rails.rb:74:in`process’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/  
mongrel.rb:159:in `process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:158:in`each’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/  
mongrel.rb:158:in `process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:285:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/  
mongrel.rb:285:in `initialize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:285:in`new’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/  
mongrel.rb:285:in `run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:268:in`initialize’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/  
mongrel.rb:268:in `new' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:268:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/  
mongrel/configurator.rb:282:in `run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel/configurator.rb:281:in`each’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/  
mongrel/configurator.rb:281:in `run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails: 133:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/  
mongrel/command.rb:212:in `run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails: 286 /usr/local/bin/mongrel_rails:19:in`load’  
/usr/local/bin/mongrel\_rails:19

Rendering /users/home/…/web/public/500.html (500 Internal Server  
Error)

This is what the access\_log said:

“POST /admin/assets/14/remove HTTP/1.1” 500 256 “http://…/admin/  
assets/14/remove”

The error\_log or the mongrel.log said nothing at all about it.

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 31, 2009, 6:04pm UTC](https://www.ruby-forum.com/t/cache-home-page-prevent-the-long-delay/158373/18 "2009-01-31T18:04:43Z")

</div>

I’ve resolved the problem or at least it works okay now.

My code looked like this:

def flush\_deletes #:nodoc:  
logger.info("[paperclip] Deleting files for #{name}")  
@queued\_for\_delete.each do |path|  
begin  
logger.info("[paperclip] -\> #{path}")  
FileUtils.rm(path) if File.exist?(path)  
rescue Errno::ENOENT =\> e  
# ignore file-not-found, let everything else pass  
end  
begin  
while(true)  
path = File.dirname(path)  
FileUtils.rmdir(path)  
end  
rescue Errno::ENOTEMPTY, Errno::ENOENT, Errno::EINVAL,  
Errno::ENOTDIR  
# Stop trying to remove parent directories  
end  
end  
@queued\_for\_delete = []  
end

When I compared it to Oldham’s code I noticed that mine had this extra:

```
      begin
         while(true)
           path = File.dirname(path)
           FileUtils.rmdir(path)
         end
       rescue Errno::ENOTEMPTY, Errno::ENOENT, Errno::EINVAL,

```

Errno::ENOTDIR  
# Stop trying to remove parent directories  
end

Once I removed it the extension worked without error.

Thanks for your help.

Steven
