On Saturday 16 July 2005 01:49, David Teare wrote:> Hi all,
>
> I am starting to play with page caching and while it is working,
I''m
> curious if there is an easier way.
>
> I have a Util controller that generates a single JS file from many
> smaller ones s.t. the page only requires one request to the server to
> get all the JS code. I thought this was an excellent candidate for
> page caching and added the following to my controller:
>
> caches_page :store_js
>
> Now, it cached the file under public/util as expected, but it was
> given an html extension. This causes a problem because if I request
> simply /util/store_js, the Rails code runs and re-generates the
> file. If I request /util/store_js.html, it works __if it was already
> cached__. If the page was not already cached, I get a "no action
> responded to this request".
>
> To ensure the controller would be called during a cache-miss, I
> fiddled with the routes.rb to map the ".html" request to the real
> controller:
>
> map.connect ''/util/store_js.html'', :controller =>
> ''util'', :action => ''store_js''
>
> And in the HTML I have the following funny-looking JS include
> statement:
>
> <script src="/util/store_js.html"
> type="text/javascript"></script>
>
>
> I would like to get rid of the entry in routes.rb, but most
> importantly I would like to have the page cached with a "js"
> extension. Is this possible?
>
> Thanks in advance,
> --Dave.
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
I found this when Googling a few days ago:
http://scottraymond.net/articles/2005/07/05/caching-images-in-rails
http://216.239.59.104/search?q=cache:I1OVdw2MKzkJ:scottraymond.net/articles/2005/07/05/caching-images-in-rails+rails+page+caching+images&hl=en&ie=UTF-8
I guess Scott is on the mailing list, if so, thanks Scott! :-)
--
Dominic Marks