# How to invoke a GET request to home page

**URL:** <https://www.ruby-forum.com/t/how-to-invoke-a-get-request-to-home-page/109425>\
**Category:** Rails\
**Created:** [July 14, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/how-to-invoke-a-get-request-to-home-page/109425 "2007-07-14T18:36:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [July 14, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/how-to-invoke-a-get-request-to-home-page/109425/1 "2007-07-14T18:36:15Z")

</div>

The homepage of my application has time sensitive data. The homepage is  
cached for fast loading.

However I clean out the cache every day midnight. It means the first  
person  
who hits the after the cache clean up has to wait extra long.

The cache is cleaned out using a rake job. Is there a way I could write  
a  
rake job to just go and hit the homepage and generate the cache page  
just  
after the cache is cleaned out.

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [July 15, 2007, 9:29am UTC](https://www.ruby-forum.com/t/how-to-invoke-a-get-request-to-home-page/109425/2 "2007-07-15T09:29:13Z")

</div>

Raj S. wrote:

> The homepage of my application has time sensitive data. The homepage is  
> cached for fast loading.
> 
> However I clean out the cache every day midnight. It means the first  
> person  
> who hits the after the cache clean up has to wait extra long.
> 
> The cache is cleaned out using a rake job. Is there a way I could write  
> a  
> rake job to just go and hit the homepage and generate the cache page  
> just  
> after the cache is cleaned out.

create the task to run in the correct order (after the cache is cleaned  
out) and put in a dependency to run the following ruby-code

```
require 'net/http'
Net::HTTP.get_print 'www.my-rails-domain.com', '/'

```

…would this work?

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [July 16, 2007, 12:47am UTC](https://www.ruby-forum.com/t/how-to-invoke-a-get-request-to-home-page/109425/3 "2007-07-16T00:47:29Z")

</div>

That would work, However I would suggest a different approach,  
consider looking at CRON if your on a linux computer and adding the  
rake task to the cron tab. This will run rake at certian time  
intervals and will work even after a restart. Most shared hosts allow  
you to run cron tasks.

On Jul 15, 5:29 pm, Shai R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
