Search code examples
azureazure-cdn

Azure CDN - difference between "Ignore query strings" and "Bypass caching for query strings"


Despite the following being mentioned in the documentation, I don't know what the exact difference is in practice between "Ignore query strings" and "bypass caching for query strings".

From the doc:

Ignore query strings: Default mode. In this mode, the CDN point-of-presence (POP) node passes the query strings from the requestor to the origin server on the first request and caches the asset. All subsequent requests for the asset that are served from the POP ignore the query strings until the cached asset expires.

Bypass caching for query strings: In this mode, requests with query strings are not cached at the CDN POP node. The POP node retrieves the asset directly from the origin server and passes it to the requestor with each request.

If my url is: mydomain.com/articles?page=3. Wouldn't this mean that the page query string is simply being ignored in both cases. What would be the difference in that case?


Solution

  • Ignore query strings

    The first request is forwarded to the origin server and the response is cached. Following requests are served from the cache whatever the query string.

    Request1:
    Browser (mydomain.com/articles?page=3) -> Azure CDN -> Server (mydomain.com/articles?page=3)
    
    Request2:
    Browser (mydomain.com/articles?page=42) -> Azure CDN (from cached whatever the query string)
    
    Request3:
    Browser (mydomain.com/otherpage?page=3) -> Azure CDN -> Server (mydomain.com/otherpage?page=3)
    

    bypass caching for query strings

    Azure CDN doesn't cache the requests that have a query string

    Request1:
    Browser (mydomain.com/articles?page=3) -> Azure CDN -> Server (mydomain.com/articles?page=3)
    
    Request2:
    Browser (mydomain.com/articles?page=3) -> Azure CDN -> Server (mydomain.com/articles?page=3)
    

    Cache every unique URL

    Request1:
    Browser (mydomain.com/articles?page=3) -> Azure CDN -> Server (mydomain.com/articles?page=3)
    
    Request2:
    Browser (mydomain.com/articles?page=3) -> Azure CDN (from cache)
    
    Request3:
    Browser (mydomain.com/articles?page=42) -> Azure CDN -> Server (mydomain.com/articles?page=42)