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













2















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.










share|improve this question



























    2















    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.










    share|improve this question

























      2












      2








      2








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 '13 at 17:00









      Kevin WorthingtonKevin Worthington

      2672517




      2672517






















          2 Answers
          2






          active

          oldest

          votes


















          5














          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)






          share|improve this answer


























          • 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





















          0














          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?






          share|improve this answer























            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            5














            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)






            share|improve this answer


























            • 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


















            5














            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)






            share|improve this answer


























            • 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
















            5












            5








            5







            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)






            share|improve this answer















            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)







            share|improve this answer














            share|improve this answer



            share|improve this answer








            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





















            • 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















            0














            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?






            share|improve this answer




























              0














              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?






              share|improve this answer


























                0












                0








                0







                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?






                share|improve this answer













                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?







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 11 mins ago









                behnam bahadoribehnam bahadori

                11




                11






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

                    Список ссавців Італії Природоохоронні статуси | Список |...

                    Українські прізвища Зміст Історичні відомості |...