Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Widget Caching
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Alex Chaffee  
View profile  
 More options Dec 21 2009, 8:23 pm
From: Alex Chaffee <a...@stinky.com>
Date: Mon, 21 Dec 2009 17:23:51 -0800
Local: Mon, Dec 21 2009 8:23 pm
Subject: Widget Caching
I just checked in some experimental code for widget caching. Here's the lowdown:

* declare a widget as "cachable" (or "cacheable") in its class file
* when it's first rendered (in #to_s or #widget) it'll save the
rendered text off into a hash table
* next time it's rendered it'll use that text instead
* the widget is keyed off of class and parameters (but not block -- in
fact, if the widget takes a block then it's not cachable at all,
sorry)
* the hash is tied to the Widget class so it stays around forever (or
until server restart, whichever comes first)... but I'd like to move
to Moneta so we can use memcache or Redis or maybe just an in-memory
LRU cache

I also made Page's HEAD emit only the externals from widgets that were
actually rendered on it, not all externals from everywhere in
ObjectSpace like it was before.

It's on the "output" branch but I'd like to get some resolution on the
Rails issues from the other thread so we can get this stuff onto the
main branch.

http://github.com/pivotal/erector/commit/9c6bdca1ae33f81cb02cc0129a4c...
http://github.com/pivotal/erector/commit/9bd07ccf67cf821f403af135ca2b...

---
Alex Chaffee - a...@cohuman.com - http://alexch.github.com
Stalk me: http://friendfeed.com/alexch | http://twitter.com/alexch |
http://alexch.tumblr.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Firebaugh  
View profile   Translate to Translated (View Original)
 More options Dec 22 2009, 1:36 pm
From: John Firebaugh <john.fireba...@gmail.com>
Date: Tue, 22 Dec 2009 10:36:10 -0800
Local: Tues, Dec 22 2009 1:36 pm
Subject: Re: [erector] Widget Caching

> It's on the "output" branch but I'd like to get some resolution on the
> Rails issues from the other thread so we can get this stuff onto the
> main branch.

Working on it.

Would anyone object to changing Widget#h to be idempotent, i.e.
h(text) returns raw(text.html_escape), and h(h(text)) doesn't
double-escape? It would make integrating with rails output safety
easier, would match the behavior of ERB::Util.h in rails 3.0 and
2.3+rails_xss plugin, and we could remove this warning:

    # Note that the #text method automatically HTML-escapes
    # its parameter, so be careful *not* to do something like text(h("2<4"))
    # since that will double-escape the less-than sign (you'll get
    # "2&amp;lt;4" instead of "2&lt;4").


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Peterson  
View profile  
 More options Dec 22 2009, 4:15 pm
From: Andy Peterson <a...@carbonfive.com>
Date: Tue, 22 Dec 2009 13:15:49 -0800
Local: Tues, Dec 22 2009 4:15 pm
Subject: Re: [erector] Widget Caching

Since you're asking,
I would prefer to work on muting the warning rather than having the h
routine not do what it is told.

My reasoning is that trying to make an encoding method idempotent doesn't
really seem
feasible.  Without some additional metadata, it doesn't know whether the
text is was
given was encoded yet... then it starts making heuristic guesses which are
harder for
programmers to reason about and use.

Sometimes I want 2<4, sometimes 2&lt;4, and sometimes even 2&amp;lt;4.

Andy

On Tue, Dec 22, 2009 at 10:36 AM, John Firebaugh
<john.fireba...@gmail.com>wrote:

--
Andy Peterson | Carbon Five | 415.546.0500 x17 |
mailto:a...@carbonfive.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Firebaugh  
View profile  
 More options Dec 22 2009, 4:34 pm
From: John Firebaugh <john.fireba...@gmail.com>
Date: Tue, 22 Dec 2009 13:34:57 -0800
Local: Tues, Dec 22 2009 4:34 pm
Subject: Re: [erector] Widget Caching
It's not a ruby interpreter warning I'm talking about, it's an
admonition in the documentation for the method -- warning you, in
effect, to watch out for the fact that it is not idempotent.

The way idempotency is accomplished is by tagging the result with a
special String subclass (RawString) and then checking for the presence
of that tag (albeit a bit indirectly, in order to be compatible with
rails and other libraries with a similar concept).

It is still quite possible to output 2<4, 2&lt;4 or 2&amp;lt;4. Choose between:

rawtext "2<4" # => "2<4"
text! "2<4" # => "2<4"
text "2<4" # => "2&lt;4"
text "2&lt;4" # => "2&amp;lt;4"
text CGI.html_escape("2<4") # => "2&amp;lt;4"

Patch:

http://github.com/bigfix/erector/commit/838ed3c38f8959dd24676752c26eb...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »