Uploaded image for project: 'Planet4'
  1. Planet4
  2. PLANET-5569

Cache rest api endpoints in OpenResty

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Won't Fix
    • Icon: Should have Should have
    • None
    • None

      We recently started adding endpoints to fetch certain data used by frontend rendered blocks. Unfortunately the performance of these endpoints is quite bad (.5 to 1 second response time). Currently these GET requests are not cached by Cloudflare, which is probably because they use a query string to pass the post id (e.g. https://github.com/greenpeace/planet4-plugin-gutenberg-blocks/blob/58caa8c87fcc38d3632486b702c078738fa118fa/assets/src/blocks/Articles/useArticlesFetch.js#L43-L43 ), which could need configuration in Cloudflare.

      Tested changing the nginx config to allow caching for these requests here https://github.com/greenpeace/planet4-docker/compare/cache-custom-endpoints. I didn't want to remove the rule to not cache things with a query string, so instead I added an override for those endpoints. But if it would be possible to remove the cache bypass for urls with a query string that would be better.

      Tasks

      • Test caching these endpoints in OpenResty, before we enable caching in Cloudflare
      • Check default Cache TTL of OpenResty
      • Investigate adding a Cache header for the browser

            Unassigned Unassigned
            pvincent Pieter Vincent (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: