Navigation

    APPDRAG Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular

    REMINDER

    Please be respectful of all AppDragers! Keep it really civil so that we can make the AppDrag community of builders as embracing, positive and inspiring as possible.

    SOLVED Cache isn't working?

    Cloud Backend (Cloud DB, API Builder)
    4
    15
    1336
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Thomas D last edited by Thomas D

      I'm having issues keeping the cache for the amount of time that's it is configured for.

      1. I load the page and it is a Cache MISS
      2. I reload again and it's a Cache HIT
      3. I wait 1 minute and it's a Cache MISS...

      I've configured Cache Duration to 14400 seconds, but it seems to be entirely ignored.

      Wassim 1 Reply Last reply Reply Quote 0
      • Wassim
        Wassim @Thomas D last edited by

        @thomasd hello,

        • What AppDrag component are you referring to ? A website page ? A Cloud API Function ? Which method (GET/POST) ?
        • How do you define the cache?
        • What do you see in the response headers for the cache duration?
        T 3 Replies Last reply Reply Quote 0
        • T
          Thomas D @Wassim last edited by Thomas D

          @wassim

          • It's a GET request, but the page uses Cloud API function to render HTML.
          • It uses Query parameters, but even when they're the same (no change), there's no cache.
          • What do you mean? It's only a setting under Optimize?

          The headers:
          ed846c36-9e95-41cc-a83c-9eaf0b20ebd0-Image 2021-07-19 at 8.29.33 AM.jpg

          Request headers:
          1190b753-9e23-40af-8ad8-19ba8677e54e-Image 2021-07-19 at 8.32.58 AM.jpg

          1 Reply Last reply Reply Quote 0
          • T
            Thomas D @Wassim last edited by Thomas D

            @wassim

            Here's without Cloudflare and a page without Query Parameters:

            8b1d3470-35dd-439f-80a9-5824bccfcc80-Image 2021-07-19 at 8.36.58 AM.jpg

            1 Reply Last reply Reply Quote 0
            • T
              Thomas D @Wassim last edited by

              @wassim

              Just tried with a blank page, same issue, cache only lasts a few seconds...

              1 Reply Last reply Reply Quote 0
              • J
                jbenguira last edited by

                Hey Thomas,
                You have not disclosed the url so I can't check...

                T 1 Reply Last reply Reply Quote 0
                • T
                  Thomas D @jbenguira last edited by

                  @jbenguira I've sent them in a PM

                  Joseph Benguira 1 Reply Last reply Reply Quote 0
                  • Joseph Benguira
                    Joseph Benguira @Thomas D last edited by Joseph Benguira

                    @thomasd OK I checked your url and PM
                    in fact caching affect only resources, not the HTML pages ...
                    in our setup .html files are always returned with this header

                    cache-control: public, must-revalidate, max-age=0
                    

                    but it will still be cached for a maximum of 30 seconds

                    FYI from a cloud function (in gateway mode) you can set any http header
                    including something like this
                    cache-control: max-age=14400

                    Since you use Cloudflare, another option is to activate caching from there
                    you can do that with a "Page Rule"

                    T 1 Reply Last reply Reply Quote 1
                    • T
                      Thomas D @Joseph Benguira last edited by Thomas D

                      @joseph-benguira

                      I've tried using Cloudflares pagerule "Cache everything" - but since the headers invalidate cache, Cloudflare will do the same and set pages to "Dynamic" mode.

                      From cloudflare:
                      "Whether we actually store the asset and for how long is determined by the Cache-Control headers returned with responses from the origin server"

                      Using Edge Cache TTL makes it possible, but that disables all cookies....

                      This means the potential API requests for this site with 400 products and 2x languages would be 2.3M requests in 24 hours....

                      Can you please change the admin text for cache duration, it's very missleading if it's only for assets and not content (as the text says).

                      1 Reply Last reply Reply Quote 0
                      • Joseph Benguira
                        Joseph Benguira last edited by Joseph Benguira

                        Hey @ThomasD , we fixed yesterday an issue with this cache option, this has bee published in production last night.

                        I can now see your cache duration correctly applied 🙂

                        Could you check again and confirm it's now all good?

                        T 2 Replies Last reply Reply Quote 1
                        • T
                          Thomas D @Joseph Benguira last edited by

                          @joseph-benguira

                          Thanks! It's now working as I expected it to, at rocket speed 🙂 🚀

                          1 Reply Last reply Reply Quote 1
                          • T
                            Thomas D @Joseph Benguira last edited by Thomas D

                            @joseph-benguira
                            Is Cache on a per-session basis?

                            If I reload until I have "Hit from cloudfront" and then change to another browser, I'll get a "Miss from cloudfront".

                            Shouldn't the other browser get the Cache hit as well?

                            J 1 Reply Last reply Reply Quote 0
                            • J
                              jbenguira @Thomas D last edited by

                              @thomasd no it's not based on sessions but based on headers, so different browsers will pass different user agent and so are cached differently

                              T 1 Reply Last reply Reply Quote 0
                              • T
                                Thomas D @jbenguira last edited by

                                @jbenguira

                                So, every new unique visitor will be served a fresh page-view, right?

                                J 1 Reply Last reply Reply Quote 0
                                • J
                                  jbenguira @Thomas D last edited by jbenguira

                                  @thomasd nop, not all headers are making the cache vary, and most users will use chrome, safari or Firefox

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post