# Adding Caching to Custom handler

**URL:** <https://www.ruby-forum.com/t/adding-caching-to-custom-handler/219276>\
**Category:** NGINX\
**Created:** [April 26, 2012, 10:11am UTC](https://www.ruby-forum.com/t/adding-caching-to-custom-handler/219276 "2012-04-26T10:11:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [April 26, 2012, 10:11am UTC](https://www.ruby-forum.com/t/adding-caching-to-custom-handler/219276/1 "2012-04-26T10:11:19Z")

</div>

Hi Guys,

I wanted to know, if I can use nginx caching techniques in my handler.  
There is no backend server and I cannot use proxy\_pass.

I wanted to store contents from some other library. For example:

location /cdn {  
myhandler;  
proxy\_cache my-cache;  
proxy\_cache\_valid 200 302 60m;  
proxy\_cache\_valid 404 1m;  
}

I think this will not work.

Can anyone help me how I can achieve caching in my handler.

Thanks,  
Raul

---

<div class="post-metadata">

**Author:** ![Sammy\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac91a4/32.png) [@Sammy\_R](https://www.ruby-forum.com/u/Sammy_R)\
**Post date:** [April 26, 2012, 1:22pm UTC](https://www.ruby-forum.com/t/adding-caching-to-custom-handler/219276/2 "2012-04-26T13:22:28Z")

</div>

On Apr 26, 2012, at 4:10 AM, Sammy R. wrote:

> Can anyone help me how I can achieve caching in my handler.

You can add the http file cache stuff to your handler. It’s not too  
hard, but not documented very well. If you can write an nginx handler,  
then you already have the skills needed.

–Brian
