nginx limit request to location based on sent bytes

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have a location with static files, served when manifest file changed, so I want to count number of bytes_sent from this location and if rate of number is higher than N, to answer 304 for the manifest file (in case of 'if-none-match' header is present), so it would reduce spikes when application updated, making clients to update slower (we have about 1k/s request ratio for manifest updates).



I checked rate_limit, but it seems can't limit by bytes_sent and also it's "measure" and "block" parts are in the same directive, so I can't block access to manifest location based on static files sent. Also I not sure if it is a good way to rewrite 40x error to 304 using named location.



I checked the lua scripting, it looks promisable, but I not found a good way to run the script worker permanently and reduce bytes in limit bucket each second.



What other direction you would suggest to solve the problem ?










share|improve this question



























    up vote
    0
    down vote

    favorite












    I have a location with static files, served when manifest file changed, so I want to count number of bytes_sent from this location and if rate of number is higher than N, to answer 304 for the manifest file (in case of 'if-none-match' header is present), so it would reduce spikes when application updated, making clients to update slower (we have about 1k/s request ratio for manifest updates).



    I checked rate_limit, but it seems can't limit by bytes_sent and also it's "measure" and "block" parts are in the same directive, so I can't block access to manifest location based on static files sent. Also I not sure if it is a good way to rewrite 40x error to 304 using named location.



    I checked the lua scripting, it looks promisable, but I not found a good way to run the script worker permanently and reduce bytes in limit bucket each second.



    What other direction you would suggest to solve the problem ?










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a location with static files, served when manifest file changed, so I want to count number of bytes_sent from this location and if rate of number is higher than N, to answer 304 for the manifest file (in case of 'if-none-match' header is present), so it would reduce spikes when application updated, making clients to update slower (we have about 1k/s request ratio for manifest updates).



      I checked rate_limit, but it seems can't limit by bytes_sent and also it's "measure" and "block" parts are in the same directive, so I can't block access to manifest location based on static files sent. Also I not sure if it is a good way to rewrite 40x error to 304 using named location.



      I checked the lua scripting, it looks promisable, but I not found a good way to run the script worker permanently and reduce bytes in limit bucket each second.



      What other direction you would suggest to solve the problem ?










      share|improve this question















      I have a location with static files, served when manifest file changed, so I want to count number of bytes_sent from this location and if rate of number is higher than N, to answer 304 for the manifest file (in case of 'if-none-match' header is present), so it would reduce spikes when application updated, making clients to update slower (we have about 1k/s request ratio for manifest updates).



      I checked rate_limit, but it seems can't limit by bytes_sent and also it's "measure" and "block" parts are in the same directive, so I can't block access to manifest location based on static files sent. Also I not sure if it is a good way to rewrite 40x error to 304 using named location.



      I checked the lua scripting, it looks promisable, but I not found a good way to run the script worker permanently and reduce bytes in limit bucket each second.



      What other direction you would suggest to solve the problem ?







      nginx






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 27 at 14:36

























      asked Sep 27 at 14:23









      zb'

      14619




      14619

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471838%2fnginx-limit-request-to-location-based-on-sent-bytes%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471838%2fnginx-limit-request-to-location-based-on-sent-bytes%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)