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


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Surfer
  3. Custom Cache-control headers

Custom Cache-control headers

Scheduled Pinned Locked Moved Surfer
8 Posts 4 Posters 1.3k Views 3 Watching
  • 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.
  • njN Offline
    njN Offline
    nj
    wrote on last edited by nj
    #1

    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 / Coder • My Apps

    1 Reply Last reply
    2
    • njN Offline
      njN Offline
      nj
      wrote on last edited by
      #2

      @staff
      Tagging for visibility of the post.

      Founder / Coder • My Apps

      1 Reply Last reply
      0
      • nebulonN Away
        nebulonN Away
        nebulon
        Staff
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • marcusquinnM Offline
          marcusquinnM Offline
          marcusquinn
          wrote on last edited by
          #4

          Even a setting of a few seconds is useful

          Web Design https://www.evergreen.je
          Development https://brandlight.org
          Life https://marcusquinn.com

          1 Reply Last reply
          0
          • nebulonN Away
            nebulonN Away
            nebulon
            Staff
            wrote on last edited by
            #5

            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
            0
            • nebulonN Away
              nebulonN Away
              nebulon
              Staff
              wrote on last edited by
              #6

              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
              0
              • girishG Offline
                girishG Offline
                girish
                Staff
                wrote on last edited by
                #7

                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
                0
                • girishG Offline
                  girishG Offline
                  girish
                  Staff
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Bookmarks
                  • Search