Multiple Cache Object for same file

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

Multiple Cache Object for same file

vergil
We are observing that multiple cache object is getting created for same file
in Nginx Cache which is resulting into non optimal use of cache storage.

We are using proxy_cache_key as $uri.

proxy_cache_key         $uri;

For example with file having URI
/content/entry/jiomags/content/719/51/51_t_0.jpg

2 cache object has been created in cache folder. Both the files are having
same KEY

-rw------- 1 nginx nginx 21023 Jun 27 16:11
./2/95/9d78505da184e6ccd981fefe6b333952
-rw------- 1 nginx nginx 21023 Jun 27 18:16
./f/ad/c8e1c56031a14dd4a27e538956253adf

 vi ./2/95/9d78505da184e6ccd981fefe6b333952

KEY: /content/entry/jiomags/content/719/51/51_t_0.jpg
HTTP/1.1 200 OK^M
Server: nginx^M
Date: Sat, 27 Jun 2020 10:41:01 GMT^M
Content-Type: image/jpeg^M
Content-Length: 20369^M
Connection: close^M
Last-Modified: Fri, 10 Jan 2020 15:20:59 GMT^M
Vary: Accept-Encoding^M
ETag: "5e18965b-4f91"^M
Expires: Sun, 26 Jul 2020 20:17:15 GMT^M
Cache-Control: max-age=2592000^M
Access-Control-Allow-Origin: *^M
Access-Control-Expose-Headers: Content-Length,Content-Range^M
Access-Control-Allow-Headers: Range^M
Accept-Ranges: bytes^

 vi ./f/ad/c8e1c56031a14dd4a27e538956253adf

KEY: /content/entry/jiomags/content/719/51/51_t_0.jpg
HTTP/1.1 200 OK^M
Server: nginx^M
Date: Sat, 27 Jun 2020 12:46:06 GMT^M
Content-Type: image/jpeg^M
Content-Length: 20369^M
Connection: close^M
Last-Modified: Fri, 10 Jan 2020 15:20:59 GMT^M
Vary: Accept-Encoding^M
ETag: "5e18965b-4f91"^M
Expires: Mon, 27 Jul 2020 12:46:06 GMT^M
Cache-Control: max-age=2592000^M
Access-Control-Allow-Origin: *^M
Access-Control-Expose-Headers: Content-Length,Content-Range^M
Access-Control-Allow-Headers: Range^M
Accept-Ranges: bytes^M

What could be the reason for duplicate file getting cached having same URI
and KEY.
Please help

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,288520,288520#msg-288520

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

Re: Multiple Cache Object for same file

Maxim Dounin
Hello!

On Thu, Jul 02, 2020 at 05:06:17AM -0400, anish10dec wrote:

> We are observing that multiple cache object is getting created for same file
> in Nginx Cache which is resulting into non optimal use of cache storage.
>
> We are using proxy_cache_key as $uri.
>
> proxy_cache_key         $uri;
>
> For example with file having URI
> /content/entry/jiomags/content/719/51/51_t_0.jpg
>
> 2 cache object has been created in cache folder. Both the files are having
> same KEY
>
> -rw------- 1 nginx nginx 21023 Jun 27 16:11
> ./2/95/9d78505da184e6ccd981fefe6b333952
> -rw------- 1 nginx nginx 21023 Jun 27 18:16
> ./f/ad/c8e1c56031a14dd4a27e538956253adf
>
>  vi ./2/95/9d78505da184e6ccd981fefe6b333952

[...]

> Vary: Accept-Encoding^M

[...]

> What could be the reason for duplicate file getting cached having same URI
> and KEY.
> Please help

The reason is the "Vary: Accept-Encoding" header line returned by
your backend.  If you want nginx to ignore it, consider using
"proxy_ignore_headers Vary;", see
http://nginx.org/r/proxy_ignore_headers for details.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx