How to set Varnish so that it doesn't cache a specific URL with a query string?Bypass cache for mobile user...
What will happen if my luggage gets delayed?
Did Amazon pay $0 in taxes last year?
Is divide-by-zero a security vulnerability?
Help find my computational error for logarithms
Recommendation letter by significant other if you worked with them professionally?
PTIJ: Why does only a Shor Tam ask at the Seder, and not a Shor Mu'ad?
Specifying a starting column with colortbl package and xcolor
How to draw dashed arc of a circle behind pyramid?
How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?
When a wind turbine does not produce enough electricity how does the power company compensate for the loss?
Giving a career talk in my old university, how prominently should I tell students my salary?
Which situations would cause a company to ground or recall a aircraft series?
Plausibility of Mushroom Buildings
Why does cron require MTA for logging?
Do items de-spawn?
What can I do if someone tampers with my SSH public key?
What do *foreign films* mean for an American?
Should I take out a loan for a friend to invest on my behalf?
How exactly does an Ethernet collision happen in the cable, since nodes use different circuits for Tx and Rx?
Is this Paypal Github SDK reference really a dangerous site?
Why aren't there more Gauls like Obelix?
Is it a Cyclops number? "Nobody" knows!
Why couldn't the separatists legally leave the Republic?
How can I manipulate the output of Information?
How to set Varnish so that it doesn't cache a specific URL with a query string?
Bypass cache for mobile user agents, VARNISH+NGINX+W3CACHEThe strange case of Mr. Time To First ByteVarnish purge is not working. Have some errors in syslognginx and varnish for caching forcing sslNginx no-cache header for ?random query stringNginx with wordpress refused varnish static content requestsVarnish cache with NGINX files not updating WordPressNginx reverse proxy and wordpressRestrict varnish purge requests to wordpress logged in usersI think Varnish is dropping my query string parameters
Server setup: Ubuntu 12.10, Varnish 3.0.2, Nginx 1.3.14, with a WordPress 3.5.1 install.
We are using the "Random Redirect" plugin which shows a random blog post at the URL http://example.com/?random
I would like to set Varnish to not cache the above URL, since currently the "random" post keeps showing the same post.
A specific snippet to show what to put in default.vcl would be super helpful. Thanks.
ubuntu nginx wordpress varnish
add a comment |
Server setup: Ubuntu 12.10, Varnish 3.0.2, Nginx 1.3.14, with a WordPress 3.5.1 install.
We are using the "Random Redirect" plugin which shows a random blog post at the URL http://example.com/?random
I would like to set Varnish to not cache the above URL, since currently the "random" post keeps showing the same post.
A specific snippet to show what to put in default.vcl would be super helpful. Thanks.
ubuntu nginx wordpress varnish
add a comment |
Server setup: Ubuntu 12.10, Varnish 3.0.2, Nginx 1.3.14, with a WordPress 3.5.1 install.
We are using the "Random Redirect" plugin which shows a random blog post at the URL http://example.com/?random
I would like to set Varnish to not cache the above URL, since currently the "random" post keeps showing the same post.
A specific snippet to show what to put in default.vcl would be super helpful. Thanks.
ubuntu nginx wordpress varnish
Server setup: Ubuntu 12.10, Varnish 3.0.2, Nginx 1.3.14, with a WordPress 3.5.1 install.
We are using the "Random Redirect" plugin which shows a random blog post at the URL http://example.com/?random
I would like to set Varnish to not cache the above URL, since currently the "random" post keeps showing the same post.
A specific snippet to show what to put in default.vcl would be super helpful. Thanks.
ubuntu nginx wordpress varnish
ubuntu nginx wordpress varnish
asked Mar 25 '13 at 17:00
Kevin WorthingtonKevin Worthington
2672517
2672517
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Putting the following block in vcl_recv
should do it:
if ( req.url ~ "^/?random" ) {
return (pass);
}
When you return(pass)
, you will jump past the opportunity to look up the request in the cache.
The default behavior is to do a bunch of tests to see if it is likely that the content is dynamic (does it set cookies, does it require authentication, is it a POST-request, things like that) - if none of those conditions are met, Varnish falls back to return(lookup)
I tried almost the exact code before posting my question and it didn't work. I tried your code and it also didn't work. I got the following errors: Command failed with error code 106 Message from VCC-compiler: Syntax error at ('input' Line 48 Pos 16) if ( req.url ~ '^/?random' ) { ---------------#-------------- Running VCC-compiler failed, exit 1 VCL compilation failed
– Kevin Worthington
Mar 26 '13 at 12:46
I'm sorry, I misquoted -- one should use""
and not''
... It compiles in my test.
– Kvisle
Mar 26 '13 at 12:50
The double quotes do compile correctly, but the random link stay the same for me still.
– Kevin Worthington
Mar 26 '13 at 12:58
I forgot to add escaping of the ?, since it was interpreted as a part of the regular expression. Again, sorry about that.
– Kvisle
Mar 26 '13 at 13:04
Yes, I think that fixed it up. Thanks Kvisle. (Giving you the check mark and voting up.)
– Kevin Worthington
Mar 26 '13 at 13:12
add a comment |
What if I want to exclude only one specific url? e.g. mydomain.com/a.
I want to exclude only /a URL, I don't want to exclude mydomain.com/category or mydoamin.com/ask. ( all url have "a" character not cache in this config)
I only want to exclude mydomain.com/a.
anyone have a idea?
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f491174%2fhow-to-set-varnish-so-that-it-doesnt-cache-a-specific-url-with-a-query-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Putting the following block in vcl_recv
should do it:
if ( req.url ~ "^/?random" ) {
return (pass);
}
When you return(pass)
, you will jump past the opportunity to look up the request in the cache.
The default behavior is to do a bunch of tests to see if it is likely that the content is dynamic (does it set cookies, does it require authentication, is it a POST-request, things like that) - if none of those conditions are met, Varnish falls back to return(lookup)
I tried almost the exact code before posting my question and it didn't work. I tried your code and it also didn't work. I got the following errors: Command failed with error code 106 Message from VCC-compiler: Syntax error at ('input' Line 48 Pos 16) if ( req.url ~ '^/?random' ) { ---------------#-------------- Running VCC-compiler failed, exit 1 VCL compilation failed
– Kevin Worthington
Mar 26 '13 at 12:46
I'm sorry, I misquoted -- one should use""
and not''
... It compiles in my test.
– Kvisle
Mar 26 '13 at 12:50
The double quotes do compile correctly, but the random link stay the same for me still.
– Kevin Worthington
Mar 26 '13 at 12:58
I forgot to add escaping of the ?, since it was interpreted as a part of the regular expression. Again, sorry about that.
– Kvisle
Mar 26 '13 at 13:04
Yes, I think that fixed it up. Thanks Kvisle. (Giving you the check mark and voting up.)
– Kevin Worthington
Mar 26 '13 at 13:12
add a comment |
Putting the following block in vcl_recv
should do it:
if ( req.url ~ "^/?random" ) {
return (pass);
}
When you return(pass)
, you will jump past the opportunity to look up the request in the cache.
The default behavior is to do a bunch of tests to see if it is likely that the content is dynamic (does it set cookies, does it require authentication, is it a POST-request, things like that) - if none of those conditions are met, Varnish falls back to return(lookup)
I tried almost the exact code before posting my question and it didn't work. I tried your code and it also didn't work. I got the following errors: Command failed with error code 106 Message from VCC-compiler: Syntax error at ('input' Line 48 Pos 16) if ( req.url ~ '^/?random' ) { ---------------#-------------- Running VCC-compiler failed, exit 1 VCL compilation failed
– Kevin Worthington
Mar 26 '13 at 12:46
I'm sorry, I misquoted -- one should use""
and not''
... It compiles in my test.
– Kvisle
Mar 26 '13 at 12:50
The double quotes do compile correctly, but the random link stay the same for me still.
– Kevin Worthington
Mar 26 '13 at 12:58
I forgot to add escaping of the ?, since it was interpreted as a part of the regular expression. Again, sorry about that.
– Kvisle
Mar 26 '13 at 13:04
Yes, I think that fixed it up. Thanks Kvisle. (Giving you the check mark and voting up.)
– Kevin Worthington
Mar 26 '13 at 13:12
add a comment |
Putting the following block in vcl_recv
should do it:
if ( req.url ~ "^/?random" ) {
return (pass);
}
When you return(pass)
, you will jump past the opportunity to look up the request in the cache.
The default behavior is to do a bunch of tests to see if it is likely that the content is dynamic (does it set cookies, does it require authentication, is it a POST-request, things like that) - if none of those conditions are met, Varnish falls back to return(lookup)
Putting the following block in vcl_recv
should do it:
if ( req.url ~ "^/?random" ) {
return (pass);
}
When you return(pass)
, you will jump past the opportunity to look up the request in the cache.
The default behavior is to do a bunch of tests to see if it is likely that the content is dynamic (does it set cookies, does it require authentication, is it a POST-request, things like that) - if none of those conditions are met, Varnish falls back to return(lookup)
edited Mar 26 '13 at 13:03
answered Mar 25 '13 at 19:03
KvisleKvisle
3,7031624
3,7031624
I tried almost the exact code before posting my question and it didn't work. I tried your code and it also didn't work. I got the following errors: Command failed with error code 106 Message from VCC-compiler: Syntax error at ('input' Line 48 Pos 16) if ( req.url ~ '^/?random' ) { ---------------#-------------- Running VCC-compiler failed, exit 1 VCL compilation failed
– Kevin Worthington
Mar 26 '13 at 12:46
I'm sorry, I misquoted -- one should use""
and not''
... It compiles in my test.
– Kvisle
Mar 26 '13 at 12:50
The double quotes do compile correctly, but the random link stay the same for me still.
– Kevin Worthington
Mar 26 '13 at 12:58
I forgot to add escaping of the ?, since it was interpreted as a part of the regular expression. Again, sorry about that.
– Kvisle
Mar 26 '13 at 13:04
Yes, I think that fixed it up. Thanks Kvisle. (Giving you the check mark and voting up.)
– Kevin Worthington
Mar 26 '13 at 13:12
add a comment |
I tried almost the exact code before posting my question and it didn't work. I tried your code and it also didn't work. I got the following errors: Command failed with error code 106 Message from VCC-compiler: Syntax error at ('input' Line 48 Pos 16) if ( req.url ~ '^/?random' ) { ---------------#-------------- Running VCC-compiler failed, exit 1 VCL compilation failed
– Kevin Worthington
Mar 26 '13 at 12:46
I'm sorry, I misquoted -- one should use""
and not''
... It compiles in my test.
– Kvisle
Mar 26 '13 at 12:50
The double quotes do compile correctly, but the random link stay the same for me still.
– Kevin Worthington
Mar 26 '13 at 12:58
I forgot to add escaping of the ?, since it was interpreted as a part of the regular expression. Again, sorry about that.
– Kvisle
Mar 26 '13 at 13:04
Yes, I think that fixed it up. Thanks Kvisle. (Giving you the check mark and voting up.)
– Kevin Worthington
Mar 26 '13 at 13:12
I tried almost the exact code before posting my question and it didn't work. I tried your code and it also didn't work. I got the following errors: Command failed with error code 106 Message from VCC-compiler: Syntax error at ('input' Line 48 Pos 16) if ( req.url ~ '^/?random' ) { ---------------#-------------- Running VCC-compiler failed, exit 1 VCL compilation failed
– Kevin Worthington
Mar 26 '13 at 12:46
I tried almost the exact code before posting my question and it didn't work. I tried your code and it also didn't work. I got the following errors: Command failed with error code 106 Message from VCC-compiler: Syntax error at ('input' Line 48 Pos 16) if ( req.url ~ '^/?random' ) { ---------------#-------------- Running VCC-compiler failed, exit 1 VCL compilation failed
– Kevin Worthington
Mar 26 '13 at 12:46
I'm sorry, I misquoted -- one should use
""
and not ''
... It compiles in my test.– Kvisle
Mar 26 '13 at 12:50
I'm sorry, I misquoted -- one should use
""
and not ''
... It compiles in my test.– Kvisle
Mar 26 '13 at 12:50
The double quotes do compile correctly, but the random link stay the same for me still.
– Kevin Worthington
Mar 26 '13 at 12:58
The double quotes do compile correctly, but the random link stay the same for me still.
– Kevin Worthington
Mar 26 '13 at 12:58
I forgot to add escaping of the ?, since it was interpreted as a part of the regular expression. Again, sorry about that.
– Kvisle
Mar 26 '13 at 13:04
I forgot to add escaping of the ?, since it was interpreted as a part of the regular expression. Again, sorry about that.
– Kvisle
Mar 26 '13 at 13:04
Yes, I think that fixed it up. Thanks Kvisle. (Giving you the check mark and voting up.)
– Kevin Worthington
Mar 26 '13 at 13:12
Yes, I think that fixed it up. Thanks Kvisle. (Giving you the check mark and voting up.)
– Kevin Worthington
Mar 26 '13 at 13:12
add a comment |
What if I want to exclude only one specific url? e.g. mydomain.com/a.
I want to exclude only /a URL, I don't want to exclude mydomain.com/category or mydoamin.com/ask. ( all url have "a" character not cache in this config)
I only want to exclude mydomain.com/a.
anyone have a idea?
add a comment |
What if I want to exclude only one specific url? e.g. mydomain.com/a.
I want to exclude only /a URL, I don't want to exclude mydomain.com/category or mydoamin.com/ask. ( all url have "a" character not cache in this config)
I only want to exclude mydomain.com/a.
anyone have a idea?
add a comment |
What if I want to exclude only one specific url? e.g. mydomain.com/a.
I want to exclude only /a URL, I don't want to exclude mydomain.com/category or mydoamin.com/ask. ( all url have "a" character not cache in this config)
I only want to exclude mydomain.com/a.
anyone have a idea?
What if I want to exclude only one specific url? e.g. mydomain.com/a.
I want to exclude only /a URL, I don't want to exclude mydomain.com/category or mydoamin.com/ask. ( all url have "a" character not cache in this config)
I only want to exclude mydomain.com/a.
anyone have a idea?
answered 11 mins ago
![](https://lh6.googleusercontent.com/-MFq2QHlt9FE/AAAAAAAAAAI/AAAAAAAAA8Q/EICtGUY965w/photo.jpg?sz=32)
![](https://lh6.googleusercontent.com/-MFq2QHlt9FE/AAAAAAAAAAI/AAAAAAAAA8Q/EICtGUY965w/photo.jpg?sz=32)
behnam bahadoribehnam bahadori
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f491174%2fhow-to-set-varnish-so-that-it-doesnt-cache-a-specific-url-with-a-query-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown