title: How can I compress the response of an ajax request?
body: <p>I return the whole HTML as the response of an ajax request <em>(not just an array as JSON)</em>. So as you know, the response will be larger a bit <em>(than JSON)</em>. Because it contains some more things like html tags, html attributes etc ... So to </p>
  
  <ul>
  <li>tncreased scalability (reduced server load).</li>
  <li>Less network bandwidth (lower cost).</li>
  <li>Better user experience (faster).</li>
  </ul>
  
  <p>I want to compress the response. Something like <code>.gzip</code> format. Based on so tests, this is the size of an ajax response:</p>
  
  <p><a href="https://i.stack.imgur.com/3muww.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3muww.png" alt="enter image description here"></a></p>
  
  <p>And this is the size of an ajax response which is zipped:</p>
  
  <p><a href="https://i.stack.imgur.com/G8E4w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G8E4w.png" alt="enter image description here"></a></p>
  
  <p>See? There is a huge different between them in theirs sizes. </p>
  
  <hr>
  
  <p>All I want to know, is it possible to compress the response of an ajax request on the way and convert it to a regular text on the client side? For doing that do I need to do some changes in the web service <em>(like nginx)</em> configuration? Or it does that automatically?</p>