Check if a resource is in the cache

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Check if a resource is in the cache

Roger Fischer
Hello,

is there a way to check if a requested resource is in the cache?

For example, “if” has the option “-f”, which could be used to check if a static file is present.

Is there something similar for a cached resource?

Thanks…

Roger

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

RE: Check if a resource is in the cache

Reinis Rozitis
> Hello,
>
> is there a way to check if a requested resource is in the cache?
>
> For example, “if” has the option “-f”, which could be used to check if a static
> file is present.
>
> Is there something similar for a cached resource?

Depending on what you want to achieve you could check $upstream_cache_status for  'HIT' ( http://nginx.org/en/docs/http/ngx_http_upstream_module.html?#var_upstream_cache_status )

rr

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx