# How do i stop rails from cacheing a link

**URL:** <https://www.ruby-forum.com/t/how-do-i-stop-rails-from-cacheing-a-link/166922>\
**Category:** Rails\
**Created:** [April 30, 2009, 10:17pm UTC](https://www.ruby-forum.com/t/how-do-i-stop-rails-from-cacheing-a-link/166922 "2009-04-30T22:17:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![morgan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/0ea827/32.png) [@morgan](https://www.ruby-forum.com/u/morgan)\
**Post date:** [April 30, 2009, 10:17pm UTC](https://www.ruby-forum.com/t/how-do-i-stop-rails-from-cacheing-a-link/166922/1 "2009-04-30T22:17:12Z")

</div>

I’ve got a controller that saves changes to a file and displays the  
file…

well, the controller the saves the file renders the controller that  
displays the file after it saves the file (i’m sure there’s a better way  
to do this but i haven’t figured it out yet).

at the bottom of the displayed file there is a link to refresh the page  
to reload the file… the problem is, unless i manually refresh the  
browser, i wont see any changes. it just keeps an old version… even  
if i just made a change to the file, it will still display the version  
before the change…

now i’m assuming this is rails wanting to be nice and cache stuff to  
make it quicker… but it’s annoying the hell out of me.

so here’s how it goes.

1.read a file with the fileread action.  
2.make changes and submit to the filewrite action which renders the  
fileread action and shows the changes just fine.  
3.click the refresh link which goes to the fileread action and the file  
reverts back to before the changes…  
4.Hit the refresh button on the browser and now the fileread action  
actually shows changes…

i can click the refresh link all i want and it still shows no change.

---

<div class="post-metadata">

**Author:** ![morgan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/0ea827/32.png) [@morgan](https://www.ruby-forum.com/u/morgan)\
**Post date:** [April 30, 2009, 10:18pm UTC](https://www.ruby-forum.com/t/how-do-i-stop-rails-from-cacheing-a-link/166922/2 "2009-04-30T22:18:37Z")

</div>

Morgan M. wrote:

> I’ve got a controller that saves changes to a file and displays the  
> file…
> 
> well, the controller the saves the file renders the controller that  
> displays the file after it saves the file (i’m sure there’s a better way  
> to do this but i haven’t figured it out yet).
> 
> at the bottom of the displayed file there is a link to refresh the page  
> to reload the file… the problem is, unless i manually refresh the  
> browser, i wont see any changes. it just keeps an old version… even  
> if i just made a change to the file, it will still display the version  
> before the change…
> 
> now i’m assuming this is rails wanting to be nice and cache stuff to  
> make it quicker… but it’s annoying the hell out of me.
> 
> so here’s how it goes.
> 
> 1.read a file with the fileread action.  
> 2.make changes and submit to the filewrite action which renders the  
> fileread action and shows the changes just fine.  
> 3.click the refresh link which goes to the fileread action and the file  
> reverts back to before the changes…  
> 4.Hit the refresh button on the browser and now the fileread action  
> actually shows changes…
> 
> i can click the refresh link all i want and it still shows no change.

i didn’t reread this before i posted it.

well, the controller the saves the file renders the controller that  
displays the file after it saves the file (i’m sure there’s a better way  
to do this but i haven’t figured it out yet).

should be

well, the action that saves the file renders the action that  
displays the file after it saves the file (i’m sure there’s a better way  
to do this but i haven’t figured it out yet).

---

<div class="post-metadata">

**Author:** ![morgan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/0ea827/32.png) [@morgan](https://www.ruby-forum.com/u/morgan)\
**Post date:** [May 1, 2009, 11:00pm UTC](https://www.ruby-forum.com/t/how-do-i-stop-rails-from-cacheing-a-link/166922/3 "2009-05-01T23:00:52Z")

</div>

Morgan M. wrote:

> now i’m assuming this is rails wanting to be nice and cache stuff to  
> make it quicker… but it’s annoying the hell out of me.

I’m guessing you’re assuming wrong here. Rails has nothing to do with  
it. It’s going to be the client’s browser that caches the file, unless  
the response tells the browser not to cache it.

Here a nice tutorial on caching that might help you:

> **[Caching Tutorial for Web Authors and Webmasters](https://www.mnot.net/cache_docs/)**
>
> Covers the how's and why's of Web caching for people who publish on the Web. With FAQs.
