<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Monika Singh on Medium]]></title>
        <description><![CDATA[Stories by Monika Singh on Medium]]></description>
        <link>https://medium.com/@monikas61789479?source=rss-477e2602dcc9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_Y-_SJcNuwomkfwu.jpg</url>
            <title>Stories by Monika Singh on Medium</title>
            <link>https://medium.com/@monikas61789479?source=rss-477e2602dcc9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 16:45:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@monikas61789479/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Wondering when to use HEAD over GET ?]]></title>
            <link>https://monikas61789479.medium.com/wondering-when-to-use-head-over-get-4a9b0f67f832?source=rss-477e2602dcc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a9b0f67f832</guid>
            <category><![CDATA[http-client]]></category>
            <category><![CDATA[http-headers]]></category>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Monika Singh]]></dc:creator>
            <pubDate>Sun, 14 Mar 2021 02:54:44 GMT</pubDate>
            <atom:updated>2021-03-14T02:54:44.414Z</atom:updated>
            <content:encoded><![CDATA[<h3>Wondering when to use HEAD over GET ?</h3><p>I definitely underestimated the power of HEAD method requests, until I landed myself into a performance trouble. So here I am to share my learning with you all in this blog post.</p><p>As you would already know, a <strong>GET</strong> method retrieves the information in the form of an entity identified by the request URI. And <strong>HEAD</strong> method is a slight modification to the <strong>GET</strong> method with all response headers and no message body response. <strong>HEAD</strong> methods are <em>safe</em>, <em>idempotent</em> and <em>cacheable</em> just like the <strong>GET</strong> methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VB3YDiU3dopt5bmeMcmbWQ.png" /></figure><h4>HEAD or GET method for your use-case ?</h4><p>If your objective is any of the following :</p><ul><li>Check if content is available or has changed at the request URI.</li><li>Check if the request URI supports any other protocol.</li><li>Know when the response cache is going to expire, so that you can request new content after expiration.</li></ul><p>Then, go ahead with the novel <strong>HEAD</strong> method request. In fact, anywhere you don’t care about the actual response body and just the metadata then <strong>HEAD</strong> is your ultimate solution.</p><p>Since the <strong>HEAD</strong> method provides us with the information of content-length in bytes , content-type , cache-control etc, we can easily meet our above mentioned objectives without paying for the bandwidth which is otherwise the case with <strong>GET</strong> requests. And this bandwidth can be extremely large when the request URI serves an audio or a video content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*spG0t4xVg2a7Z86wx_UqRQ.png" /><figcaption>Sample response header for a HEAD method request</figcaption></figure><p>So does it mean that <strong>HEAD</strong> method requests are light requests for servers too? No, unfortunately not. Since the server has to return content-length in the response header, it needs to generate the response body and calculate the length.</p><h4>Performance improvement with HEAD</h4><p>Usually the performance improvement between a <strong>HEAD</strong> and a <strong>GET</strong> method is very negligible when server is fast with the response and the message body is small. But the absolute game changer is, when the response message body is a huge download and hence takes time to respond.</p><p>Here comes my use-case, I just want to check if an audio url is resolvable. So, this is a sample <strong>GET</strong> method request which should return an audio file (It’s one of my disliked podcast 😄). As you see it took about 1.5 seconds to load for a content of size is 13.6 Mb.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YdnkdLOj4_BavTOOJmNjbA.png" /></figure><p>But wait! Do I even care about the actual content? Hell, No. So lets switch to <strong>HEAD</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EIX3HSC0ExiJ-5Kb-sPHKQ.png" /></figure><p>Noice! So now I see an improvement. It gave me what I needed in much lesser time saving my bandwidth in under 500 ms. Now let’s see its overall impact on the system in terms of CPU and memory usage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ls1GZzxv8YxRk6f9HQSsYQ.png" /><figcaption>CPU usage comparison with GET until 5th March morning and HEAD from 5th March evening</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3TPAqSKIYRdM3zkn2r0dsw.png" /><figcaption>Memory usage comparison with GET until 5th March morning and HEAD from 5th March evening</figcaption></figure><p>So, <strong>HEAD</strong> is a clear WINNER!</p><h4>Do all GET resources support HEAD method by default ?</h4><p>No, it’s not necessary but it’s recommended as per <a href="https://tools.ietf.org/html/rfc7231#section-4.1">HTTP standards</a>. Where it mentions -</p><pre>All general-purpose servers MUST support the methods GET and HEAD.<br>All other methods are OPTIONAL.</pre><p>With <a href="https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc">Spring Web MVC</a>, all the @RequestMapping for <strong>GET</strong> methods are implicitly mapped to and support <strong>HEAD</strong>. So by default all <strong>GET</strong> methods support <strong>HEAD</strong> as well. However you are free to provide any custom implementation for <strong>HEAD</strong> methods as per your use-case.</p><p>I hope this blog post gave you some clarity on the topic. If you have any question, then please feel free to drop them in the comments section.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a9b0f67f832" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>