Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

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

    Custom Cache-control headers

    Surfer
    4
    8
    69
    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.
    • nj
      nj last edited by nj

      The header currently sent by Surfer for all requests is Cache-Control: public, max-age=0

      This setting causes the browsers to re-request everything that could have been cached instead. If the max-age value could be customizable from settings or somehow else, that would be a lot less strain on the Surfer on Cloudron.

      My use-case:
      I run Surfer behind Cloudflare, and Cloudflare honors the cache settings, but only if max-age is set to a non-zero value. Basically Cloudflare is not caching anything and my Surfer instance is constantly running out of memory because of the number of requests.

      Founder & OpenSource Lover. My Cloudron Apps

      1 Reply Last reply Reply Quote 2
      • nj
        nj last edited by

        @staff
        Tagging for visibility of the post.

        Founder & OpenSource Lover. My Cloudron Apps

        1 Reply Last reply Reply Quote 0
        • nebulon
          nebulon Staff last edited by

          I think that makes sense, currently it uses the express.static() defaults only.

          1 Reply Last reply Reply Quote 0
          • marcusquinn
            marcusquinn last edited by

            Even a setting of a few seconds is useful

            We're not here for a long time - but we are here for a good time :)
            Jersey/UK
            Work & Ecommerce Advice: https://brandlight.org
            Personal & Software Tips: https://marcusquinn.com

            1 Reply Last reply Reply Quote 0
            • nebulon
              nebulon Staff last edited by

              So surfer already sets the ETag https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag but no max-age The max-age setting basically makes the browser not even check in the with server if the content may have changed.

              Now various frameworks set the max-age very high and use other cash busting techinques (like changing the file path hash) to serve up-to-date content if needed.

              For surfer this is hard to implement, as the main html pages have to be aware of this. So I am not sure how surfer can set max-age and ensure that content is fresh at the same time.

              1 Reply Last reply Reply Quote 0
              • nebulon
                nebulon Staff last edited by

                Given that this is CloudFlare acting as a browser here, I wonder if they have cache settings on their own to for example mark a subpath of the proxied app as valid for n seconds?

                1 Reply Last reply Reply Quote 0
                • girish
                  girish Staff last edited by

                  In theory , max-age=0 means the same as no-cache . no-cache means cache it but always revalidate. It seems max-age=0 allows stale reuse and thus there is also a must-revalidate to prevent that.

                  Cloudflare has it's own interpretation. Per https://developers.cloudflare.com/cache/about/default-cache-behavior , it won't cache at all with max-age=0. We have to create a custom page rule - https://developers.cloudflare.com/cache/how-to/create-page-rules/ to override the default caching behavior.

                  So... my interpreation is that we need Cache-Control: public, max-age=1, must-revalidate if we want this to work out of the box in Cloudflare.

                  1 Reply Last reply Reply Quote 0
                  • girish
                    girish Staff last edited by

                    https://learn.microsoft.com/en-us/azure/cdn/cdn-how-caching-works is an excellent read on some other interpretations.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB