# Proxy Cache - Check if file has been cached

**URL:** <https://www.ruby-forum.com/t/proxy-cache-check-if-file-has-been-cached/201112>\
**Category:** NGINX\
**Created:** [December 30, 2010, 3:58pm UTC](https://www.ruby-forum.com/t/proxy-cache-check-if-file-has-been-cached/201112 "2010-12-30T15:58:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [December 30, 2010, 3:58pm UTC](https://www.ruby-forum.com/t/proxy-cache-check-if-file-has-been-cached/201112/1 "2010-12-30T15:58:31Z")

</div>

Hi,  
I have implemented nginx with proxy cache successfully, however, I need  
to have the ability to check if a certain file is already cached or  
not.  
Is there a way to get a list of cached files?  
Maybe another way will be to send a HEAD request which contains the file  
URI to the proxy cache server to check if a file is already in cache?

Are these methods possible?

Posted at Nginx Forum:

> **[Proxy Cache - Check if file has been cached](https://forum.nginx.org/read.php?2,162263,162263#msg-162263)**
>
> Hi, I have implemented nginx with proxy cache successfully, however, I need to have the ability to check if a certain file is already cached or not. Is there a way to get a list of cached files? Maybe another way will be to send a HEAD request which...

---

<div class="post-metadata">

**Author:** ![digger18](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@digger18](https://www.ruby-forum.com/u/digger18)\
**Post date:** [December 30, 2010, 4:53pm UTC](https://www.ruby-forum.com/t/proxy-cache-check-if-file-has-been-cached/201112/2 "2010-12-30T16:53:44Z")

</div>

Checking the header “Expires” is probably the most reliable way.

Cheers,

Simon

2010/12/30 digger18 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![digger18](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@digger18](https://www.ruby-forum.com/u/digger18)\
**Post date:** [December 31, 2010, 7:02am UTC](https://www.ruby-forum.com/t/proxy-cache-check-if-file-has-been-cached/201112/3 "2010-12-31T07:02:19Z")

</div>

I use this variable $upstream\_cache\_status added to my access log to  
check  
the Hit Percentage. While I think you can also use it to check whether  
the  
file is cached.  
Add it to the log\_format in you configure file, access every file you  
want  
to check, and the cache status will be shown in the access log.
