pczerkas / kube-apps-httpcache

Varnish Reverse Proxy on Kubernetes for multiple applications
MIT License
1 stars 0 forks source link

rewrite of vcl_hash #14

Open pasztorl opened 6 months ago

pasztorl commented 6 months ago

Hi,

First, this code works great big thanks for that! My problem probably not a bug, but a question. So the backend service changes the content by the user agent defining the client is a desktop or a mobile. I've found this vcl: https://github.com/varnishcache/varnish-devicedetect and I added this to the vcl template. Now I see the extra added headers.

-   VCL_call       RECV
...
-   ReqHeader      X-UA-Device: desktop
-   VCL_use        l004_20240416_135654_82836 via l001
-   VCL_return     vcl

After doing this I defined a vcl_hash like this:

        sub vcl_hash {
            hash_data(req.url);
            hash_data(req.http.X-UA-Device);
            if (req.http.host) {
                hash_data(req.http.host);

            } else {
                hash_data(server.ip);
            }
            return (lookup);
        }

It not worked, so I checked the varnishlog:

-   VCL_call       RECV
-   VCL_return     hash
-   ReqUnset       accept-encoding: identity
-   VCL_call       HASH
-   Hash           "/article/1/1712303819_43457_abstract_dual_screen_dual_monitor_abstract_lights_dual_screen.jpg%00"
-   Hash           "example.net%00"
-   VCL_return     lookup

So it seems the custom vcl_hash not executed, the default vcl_hash used. There is a trick which I missed to modify the built-in one?

pasztorl commented 6 months ago

It looks like if the values.vclTemplate sets the header the cache.applications[*].vclTemplate not see it. Am I miss something?

pczerkas commented 5 months ago

@pasztorl sorry about that, but somehow I did not get email notification about this issue. I'l try to look at this ...