Skip to content

Add view cache for PWA manifest.json

What does this MR do and why?

This should fix #417136 (closed). Our PWA manifest.json file started out as a static file but nowadays is more dynamic. It uses values stored in the Appearance.current, so it reads from the database. The resulting manifest is always identical, as long as Appearance.current didn't change, so this is a perfect candidate for a view cache.

How to set up and validate locally

This is a bit tricky to validate.

  • First, make sure your development env has caching enabled. Run gdk rails dev:cache to toggle caching.
  • Now browse to or curl http://gdk.test:3000/-/manifest.json and check your log/development.log file.
  • In there you should find a line like this: Read fragment views/pwa/manifest:8676ce6d1e06e5c891dbfec1fe3365b0/appearances/2-20230728082920121428 (0.6ms)
  • Now update your GDK's appearance, either in the Progressive Web App (PWA) section at http://gdk.test:3000/admin/application_settings/appearance or via console: Appearance.current.update(pwa_name: 'gl pwa')
  • Now curl http://gdk.test:3000/-/manifest.json again and you should see the new values and also a Read fragment ... Write fragment ... in your logs.
  • Curl it again to again see only "Read fragment", but not "Write fragment".
  • Rails view cache also considers the view's digest, so change something in app/views/pwa/manifest.json.erb and curl again. You'll see your change immediately, even though the current_appearance hasn't changed.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Thomas Hutterer

Merge request reports

Loading