Skip to content

0.5.0

Latest

Choose a tag to compare

@stuyam stuyam released this 17 Sep 19:56

What's Changed

It will add turbo frame ids and formats to the cached urls as url params that don't get sent to the server but attach settings for controller actions that return multiple formats or respond to turbo frames.

As an example, it allows all of these respond_to responses to be cached differently per URL:

def show
  respond_to do |format|
    format.html { render html: (turbo_frame_request? ? FRAME : PAGE).html_safe }
    format.json { render json: { body: "json" } }
    format.csv { render plain: "a,b,c" }
    format.xml { render xml: "<report/>" }
    format.text { render plain: "plain" }
  end
end

For precaching urls you can also optionally specify turbo frame and formats to cache accordingly:

Coldwire.configure do |config|
  config.auto_sync do |sync|
    sync.precache_urls = ->(controller) {
      [
        "example/url",
        { url: "example/url_2", frame: "card" },
        { url: "example/url_3", format: :json },
      ]
    }
  end
end

Also since turbo streams are meant to be in response to form submissions, turbo streams are intentionally ignored now from caching.

Full Changelog: 0.4.0...0.5.0