Home > Software design >  CloudFront not caching html file
CloudFront not caching html file

Time:06-24

I am using default cache setting which is 24hours.

However, when I refresh the page, I see updated html page every time. Why the file is not cached for 24hrs. I didn't set any invalidation mechanism.

Here's the URL: https://dhr5io29ip73w.cloudfront.net/

html file content:

<html>
    <h1>Test</h1>
    <p id='myTime'></p>

    <script>
    var d = new Date().toLocaleTimeString();
    document.getElementById('myTime').innerHTML = d;
    </script>
</html>

CodePudding user response:

Your page includes JavaScript. The JavaScript code runs in the web browser. That means each time you load the page, your web browser executes those JavaScript statements in the <script> tag which includes updating the page with the current time.

CloudFront just caches the raw HTML of the page. It doesn't cache the rendered result.

  • Related