Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite of vcl_hash #14

Open
pasztorl opened this issue Apr 16, 2024 · 2 comments
Open

rewrite of vcl_hash #14

pasztorl opened this issue Apr 16, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@pasztorl
Copy link

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 pasztorl added the bug Something isn't working label Apr 16, 2024
@pasztorl
Copy link
Author

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

@pasztorl pasztorl reopened this Apr 16, 2024
@pczerkas
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants