0
votes

I've set up simple action caching for the show page of one of my models. Caches are generatedand expires correctly, however, every time a new cache is written and read for the first time, the view inserts 'escaped' HTML into the layout, meaning the web browser displays the actual cache contents rather than rendering the HTML page.

In my Uploads controller, i declared chaches like this:

caches_action :index, :show, layout: false
cache_sweeper :drumiverse_sweeper, only: [:edit, :destroy, :update]

Sweeper Class (which is executed correctly):

class UploadsSweeper < ActionController::Caching::Sweeper
observe  Upload

def after_save(record)
    puts "Expiring Caches after Saving"
    expire_action(controller: '/pages', action: 'home')
    expire_action(controller: '/pages', action: 'resources')
    expire_action(controller: '/pages', action: 'videos')


    expire_fragment('footer')

    expire_action(controller:'/uploads',action: 'index')
    expire_fragment(record)


    end
end

I used the layout: false option because i only want the action view to get cached (not the entire layout, including menu bar).

After reloading the page, the cache is read and inserted correctly and the page renders as it should. It is just the first time after writing a new cache that it actually prints out the cache contents as a HTML string.

Has anyone seen this problem before? enter image description here

1
noone encountered this before? - danielbker

1 Answers

0
votes

Switching to the master branch of the gem, which incorporates Pull Request 48 (per @steakchaser's recommendation), solved this for me on Heroku production. In the gemfile:

gem 'actionpack-action_caching', git: "https://github.com/rails/actionpack-action_caching.git", branch: "master"

Bundled, committed, and pushed.