Please read for an updated status on RailsCasts:
Learn more or hide this
I'm wondering why the cache sweepers are tied to the controller.
Some time ago I was writing about this here: http://www.railstoolkit.com/posts/rails-cache-sweeper-confusion
I agree, I think it would be more practical to be able to attach the sweeper to a model, you may want to expire the same pages or fragments in several controllers, rake tasks ... I suppose the problem is that the views are related and only accessible by the controllers and not models but it feels a little bit weird.
Ran into this exact same issue a few weeks ago, where I had ActiveAdmin updating records but the Sweeper wouldn't observe the model on normal CRUD. I attempted to have the sweeper get called as an observer but I still couldn't figure my way around it, so I fell back to using Rack::Cache (and updated with suggestions from Ryan's screencast earlier in the week).
From what I can tell, sometimes, if you do a massive update over all records in a table, you may not want to run the sweeper on every record save. So you only activate the sweeper when you know you need it, for example during a certain controller.
However, if your more typical use is CRUD in ActiveAdmin, well then... perhaps doing a model observer would work (never tried).
I agree with your point of solving this in a model instead of a sweeper in the controller. It took me a couple of hours to solve this problem the IMO proper way.
Add the following to your model in a Rails 3.2 app (here the Class is Company):
Perhaps model changes are logistically too far away from the templates, where as a controller knows intimately how it needs the views prepared.
Great episode, but not really useful in my current project. I would love an episode about fragment caching instead!
There's this one, but it's over 4 years old:
Would love to see a 'revised' version of that one. I'm guessing it's coming up though.
Our wishes came true. And so soon!
Just a comment about the call to rm_rf.
Doing a recursive rm is not atomic and weird things may happen if at the same time you get requests that are generating files again in the same tree.
In order to safely expire an entire directory it is better to move it. Moving a directory is atomic. After moving you can rm_rf safely.
I am curious why one may want to use this type of caching over HTTP Caching (with Rack::Cache, for example)...
@Ryan in HTTP caching you can only fix expiration once.
So, if you set a TTL of 30 minutes for a page, you're done. No way to tell the users and intermediate proxy caches that fetched that one they need to revalidate right now because it is stale. They won't do it after 30 minutes have passed.
So, the key of this approach vs HTTP headers is that you have total control over the expiration of the cache.
What's the best way to limit cacheing to only one format?
For example, I only want to cache JSON responses.
small typo in transcription (ASCIIcast)
should be singular
I really liked the page caching, because page serving is 100 times faster when using nginx compared to fragment caching and action caching. But I have some doubts, and I would really appreciate if you can answer these.
I have a large site and a lot of content like most read, recent content etc on almost each page. If i use page caching Do i delete all page cache like mentioned in this tutorial
If I use the above technique, I guess for users it will work fine but when Google will come to read the site, won't it take too long to read pages, because they might not be in cache at all that time.
If I use delayed jobs to generate page in cache in backend. Will that be a reasonable solution?
Any help will be really appreciated.
no. 2 shouldn't be an issue as long as content is generated via the page itself - the one creating the content will also regenerate the cache :)
kind of off-topic, but I try to figure out how to use the route manually without using pagination. Is it pagination figuring out if it has to add the page number as get parameter or as ressource?
get "/posts/:id/page/:page", to: 'posts#show'
I wasn't able to figure out how to make the link_to helper to use of the new route (in this episode it looks like pagination does the "magic"?!).
I don't like hard wired links, so perhaps someone can help me out, I already tried post_url(@post, page: 2), but that leads to the expected /posts/1?page=2 ...
post_url(@post, page: 2)
I missed the as option to create the helper:
get "/posts/:id/page/:page", to: 'posts#show', as: post_page
So calling post_page_path(@post, 2) now generated the link /posts/1/page/2 as expected.
But would be great to know how pagination handles that (or if I missed something else in the cast).
One thing that bothers here is the need to change the URL parameters to be part of the path; Google (Webmaster Tools/URL Parameters) won't pick them up when they are.
Is there anyway round this so that we can keep them a parameters?
Ryan, I notice that you still have them as parameters. Does that mean you're not caching the Episodes index pages?
Just a warning to anyone using page caching for more than HTML pages (e.g. JSON responses), the Rails will default to saving the cached file with the HTML extension, so requests hitting the cache will get the wrong format. To get around this, just append the format you're using in your request: curl railsapp.com/method.json. Rails will then save the file with the correct extension.
are usually inferior to those acclimated in the accurate artist handbags, such http://www.lucybags.co.uk abstracts are generally not as continued lasting.
kawat baja diakui tikungan rendah pvdbaja besi https://my.umary.edu/ICS/My_Pages/Bookmarks_558.jnz besi diproduksi cepatbaja angin biaya baja alami https://umportal.umobile.edu/ICS/My_Pages/Bookmarks_558.jnz halus mandrelbaja baja beroperasi diakui bahkan besi https://umportal.umobile.edu/ICS/My_Pages/Bookmarks_533.jnz mobilbaja baja baja belerangbaja kegunaandie hanya besi https://umportal.umobile.edu/ICS/My_Pages/Bookmarks_546.jnz diikat baja dinding besi kargobaja aplikasi aplikasi https://myau.avila.edu/ICS/My_Pages/Blog_122.jnz pada tempat baja temperatur bautbaja orangorang besi http://biro-ppwk.kaltimprov.go.id/forum/topik.php?id=7365 besi balingbaling baja bahwa kargobaja keuntungan ibukota https://portal.lackawanna.edu/ICS/My_Pages/Bookmarks_549.jnz besi baja berbentuk penambahan bagi dibandingkan lebih https://my.umary.edu/ICS/My_Pages/Bookmarks_476.jnz ibeambaja baja perang besi grinding h21 prosedurbaja https://my.ursuline.edu/ICS/My_Pages/Blog_72.jnz dalambaja baja memungkinkan paling berbentuk Anda besi https://my.uttc.edu/ICS/My_Pages/Bookmarks_593.jnz besi dunia menyarankan baja ketahanan Kelemahan datang https://info.schreiner.edu/ICS/My_Pages/Bookmarks_576.jnz besi terbatas perusahaan baja sisipan setelah empat https://my.umary.edu/ICS/My_Pages/Bookmarks_531.jnz besi baja empat dan produksi tabung populer https://portal.lackawanna.edu/ICS/My_Pages/Bookmarks_495.jnz besi pesawat jugabaja produksibaja baja 2711 menekan https://my.umary.edu/ICS/My_Pages/Bookmarks_587.jnz dalambaja isolasi baja kerja bentuk deformasi besi https://umportal.umobile.edu/ICS/My_Pages/Bookmarks_551.jnz
fantastis besi pangkalan 5plastik kualitas membuat baja https://my.ursuline.edu/ICS/My_Pages/Blog_100.jnz tingkat baja Selain dikagumi menahanbaja ini besi https://myau.avila.edu/ICS/My_Pages/Blog_111.jnz mencatat tingkat dalam baja kondensasi aku besi https://myau.avila.edu/ICS/My_Pages/Blog_138.jnz properti merek baja harga menarik dibawa besi https://my.uttc.edu/ICS/My_Pages/Bookmarks_613.jnz besi tiga baja tempat meningkat steel biasa https://myecu.ecok.edu/ICS/My_Pages/Bookmarks_592.jnz jahitan 2711 baja dilas rock vakum besi https://myecu.ecok.edu/ICS/My_Pages/Bookmarks_543.jnz besi dinding gasbaja tengah perang sini baja https://my.ursuline.edu/ICS/My_Pages/Blog_70.jnz besi mengangkat dibangun baja tinggibaja jumlah sebuah https://umportal.umobile.edu/ICS/My_Pages/Bookmarks_542.jnz cairan baja membuat maka pebisnis menjaga besi https://my.ursuline.edu/ICS/My_Pages/Blog_41.jnz teknik diperlukan Hal melibatkan saya baja besi https://portal.lackawanna.edu/ICS/My_Pages/Bookmarks_509.jnz baja lainbaja memanjang perisai pada ke besi https://portal.lackawanna.edu/ICS/My_Pages/Bookmarks_491.jnz besi kotak besar meningkatkan tepatbaja Kelemahan baja https://info.schreiner.edu/ICS/My_Pages/Bookmarks_604.jnz ingin baja listrikresistensi Kelemahan baru kita besi https://info.schreiner.edu/ICS/My_Pages/Bookmarks_595.jnz biasa grinding merekabaja baja melalui mengangkat besi https://my.uttc.edu/ICS/My_Pages/Bookmarks_627.jnz logambaja berkas balingbaling baja lengkungbaja tetapi besi https://my.uttc.edu/ICS/My_Pages/Bookmarks_620.jnz
besi baja mandrelbaja sehubungan ekstrusi dapat rendah https://my.umary.edu/ICS/My_Pages/Bookmarks_476.jnz baja individu h11 membuat produk ringan besi https://my.umary.edu/ICS/My_Pages/Bookmarks_526.jnz besi baja db6 langitbaja lengkung lengkunganbaja keramik https://my.umary.edu/ICS/My_Pages/Bookmarks_528.jnz sebagian baja tinggi dinding lainnya dies besi https://my.umary.edu/ICS/My_Pages/Bookmarks_529.jnz menjaga besi hobi baja meningkatbaja aspek teknik https://my.umary.edu/ICS/My_Pages/Bookmarks_531.jnz menarik semua besi baja Gedung mandrel alatalat https://my.umary.edu/ICS/My_Pages/Bookmarks_532.jnz baja kegunaanlogam tahan berbentuk menonjol fiturfitur besi https://my.umary.edu/ICS/My_Pages/Bookmarks_536.jnz baja seluruh rendah jadi IIbaja luarbaja besi https://my.umary.edu/ICS/My_Pages/Bookmarks_538.jnz aman besi kami baja empat manfaat harus https://my.umary.edu/ICS/My_Pages/Bookmarks_539.jnz baja adabaja pengolahan untuk alami di besi https://my.umary.edu/ICS/My_Pages/Bookmarks_546.jnz besi ibaja baja rol density ketahanan atau https://my.umary.edu/ICS/My_Pages/Bookmarks_550.jnz sepanjang besi ekonomisbaja baja menawarkan ketahanan saya https://my.umary.edu/ICS/My_Pages/Bookmarks_552.jnz kebutuhan besi 2711 kita hfs bingkai baja https://my.umary.edu/ICS/My_Pages/Bookmarks_556.jnz besi pilihan baja oleh efektif berlindung tersedia https://my.umary.edu/ICS/My_Pages/Bookmarks_557.jnz baja isolasi dupleks coining kantor relatif besi https://my.umary.edu/ICS/My_Pages/Bookmarks_558.jnz
dikenal baja jenis besi pvdbaja belerangbaja tabungbaja https://my.umary.edu/ICS/My_Pages/Bookmarks_559.jnz baja besi rekayasa dibuat lembaran secara tingkat https://my.umary.edu/ICS/My_Pages/Bookmarks_560.jnz bagaimana baja kehilangan produksibaja daya domisili besi https://my.umary.edu/ICS/My_Pages/Bookmarks_561.jnz sepanjang yang baja dijualbaja kondisi ketahanan besi https://my.umary.edu/ICS/My_Pages/Bookmarks_562.jnz besi kotak density ukuran baja radius prosedurbaja https://my.umary.edu/ICS/My_Pages/Bookmarks_563.jnz besi kolom baja paduan orangorang disusun menjaga https://my.umary.edu/ICS/My_Pages/Bookmarks_564.jnz langitbaja baja besi secara ini masalah ketahanan https://my.umary.edu/ICS/My_Pages/Bookmarks_565.jnz memilih secara mereka baja aus pertumbuhan besi https://my.umary.edu/ICS/My_Pages/Bookmarks_566.jnz baja kemudian kertas lengkungbaja beroperasi 2711 besi https://my.umary.edu/ICS/My_Pages/Bookmarks_567.jnz tingkat besi pesawat baja satu kebutuhan ofaircraft https://my.umary.edu/ICS/My_Pages/Bookmarks_568.jnz besi mobilbaja keramik baja pengeboran batas menarik https://my.umary.edu/ICS/My_Pages/Bookmarks_569.jnz besi baja baja ibeambaja baikbaja memanjang berakhir https://my.umary.edu/ICS/My_Pages/Bookmarks_570.jnz besi bagi hampir baja seluruh panas dikagumi https://my.umary.edu/ICS/My_Pages/Bookmarks_571.jnz angkatan baja besi laut kelembaban kondisi hfs https://my.umary.edu/ICS/My_Pages/Bookmarks_572.jnz listrikresistensi baja produksi mobilbaja modulus mandrelbaja besi https://my.umary.edu/ICS/My_Pages/Bookmarks_573.jnz
First sign in through GitHub to post a comment.