locked
Azure CDN is just 301 redirecting instead of serving content itself. RRS feed

  • Question

  • I am trying to replicate this directory:

    https://poweroutage.us/content/geometry/

    things like 

    https://poweroutage.us/content/geometry/countygeometry/maine.json

    to:

    https://geometry.azureedge.net

    and would like to use the custom domain:

    https://geometry.poweroutage.us

    What is weird though is that https://geometry.azureedge.net/countygeometry/maine.json

    is just doing a 301 redirect to https://poweroutage.us/content/geometry/countygeometry/maine.json

    instead of serving the content itself.

    What am I missing to get the CDN to actually cache the JSON files?


    Tuesday, February 20, 2018 6:01 AM

Answers

  • Your origin is returning the 301 response and the CDN is just serving it. The CDN does not follow redirects.

    Origin cURL:

    curl -svo /dev/null 'https://www.poweroutage.us/content/geometry/stategeometry.json'

    * Hostname was NOT found in DNS cache

    * Trying 191.236.16.12...

    * Connected to www.poweroutage.us (191.236.16.12) port 443 (#0)

    > GET /content/geometry/stategeometry.json HTTP/1.1

    > User-Agent: curl/7.35.0

    > Host: www.poweroutage.us

    > Accept: */*

    >

    < HTTP/1.1 301 Moved Permanently

    < Content-Length: 181

    < Content-Type: text/html; charset=UTF-8

    < Location: https://poweroutage.us/content/geometry/stategeometry.json

    * Server Microsoft-IIS/10.0 is not blacklisted

    < Server: Microsoft-IIS/10.0

    < Access-Control-Allow-Origin: *

    < Set-Cookie: ARRAffinity=c21818fc505e668fb37d3bd26d5b172816869d658369864f35fc5da37f393e91;Path=/;HttpOnly;Domain=www.poweroutage.us

    < Date: Mon, 26 Feb 2018 18:10:03 GMT


    Monday, February 26, 2018 7:55 PM

All replies

  • Hi Jason,

    I just requested the page  https://geometry.azureedge.net/countygeometry/maine.json and it is not showing a 301 redirect.

    In addition, the file appears to be cached, since I get the x-cache: HIT header back.

    Can you confirm the issue?

    Tuesday, February 20, 2018 11:08 PM
  • Weird,

    It is not doing it for that file anymore...

    It still does it for this one:

    https://geometry.azureedge.net/stategeometry.json

    So I guess that changes my question too why is Azure CDN redirecting some of the time?

    Wednesday, February 21, 2018 12:27 AM
  • Hi Jason,

    Have you setup any redirect rules in the Rules Engine?

    If not, I can see that the 301 response has a cache-control: max-age=604800, meaning that it is cached for a long time.

    You can purge the file(s) from the azure portal and try again after a few minutes.

    Wednesday, February 21, 2018 12:48 AM
  • >>Have you setup any redirect rules in the Rules Engine?

    Nope, no redirect rules.

    >>If not, I can see that the 301 response has a cache-control: max-age=604800, meaning that it is cached for a long time.

    Yeah, I have that set on the web server for the whole content folder, so that the CSS and Javascript get cached.

    I was to use the CDN for the delivery of the JSON geometry because it's large and is faster from the CDN then from the web server.

    >>you can purge the file(s) from the azure portal and try again after a few minutes.

    I tried to purge the CDN but that did not help.


    Wednesday, February 21, 2018 11:52 PM
  • Ok let me look into this a bit further for you.
    Thursday, February 22, 2018 1:38 AM
  • Your origin is returning the 301 response and the CDN is just serving it. The CDN does not follow redirects.

    Origin cURL:

    curl -svo /dev/null 'https://www.poweroutage.us/content/geometry/stategeometry.json'

    * Hostname was NOT found in DNS cache

    * Trying 191.236.16.12...

    * Connected to www.poweroutage.us (191.236.16.12) port 443 (#0)

    > GET /content/geometry/stategeometry.json HTTP/1.1

    > User-Agent: curl/7.35.0

    > Host: www.poweroutage.us

    > Accept: */*

    >

    < HTTP/1.1 301 Moved Permanently

    < Content-Length: 181

    < Content-Type: text/html; charset=UTF-8

    < Location: https://poweroutage.us/content/geometry/stategeometry.json

    * Server Microsoft-IIS/10.0 is not blacklisted

    < Server: Microsoft-IIS/10.0

    < Access-Control-Allow-Origin: *

    < Set-Cookie: ARRAffinity=c21818fc505e668fb37d3bd26d5b172816869d658369864f35fc5da37f393e91;Path=/;HttpOnly;Domain=www.poweroutage.us

    < Date: Mon, 26 Feb 2018 18:10:03 GMT


    Monday, February 26, 2018 7:55 PM
  • Thanks! This was the issue.

    The CDN was pointing the www. URL, which the web app has a URL rewrite rule to automatically remove it.

    Friday, March 16, 2018 5:15 AM