Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Re: DataSource cached response

Expand Messages
  • Satyam
    I m sorry, you did mention that you have caching explicitly enabled, which is not the default. With caching enabled the code in the example won t work.
    Message 1 of 4 , Nov 29, 2007
    • 0 Attachment
      I'm sorry, you did mention that you have caching explicitly enabled, which
      is not the default. With caching enabled the code in the example won't
      work. First, it does not cache anything but what you mention in the
      responseSchema and had already parsed. All the elements above the
      resultsList do not get cached, nor any fields under which are not listed.
      Second, it won't call doBeforeCallBack when it finds a hit, which is
      probably right since the data cached is already parsed and it got processed
      by both doBeforeXxxx methods by the time it got into the cache. (It seems to
      me those two methods were originally meant to fix the data before it reaches
      the DataTable, not to extract extra information from the response).

      Also, I noticed enabling the cache requires some tweaking, not only setting
      maxCacheEntries but also initializing _aCache, which since it starts with an
      underscore, it is supposedly private. Unless you did it in other 'legal'
      way, that is a bug.

      I guess that you'll have to handle your very own cache for pages and
      activePage numbers. DataSource mantains its cache indexed on the request,
      the first argument to sendRequest and since your data is comparatively
      little, you might not care to keep a maximum number of cached responses,
      just cache them all.

      Satyam


      ----- Original Message -----
      From: "vojtech.jasny" <vojtech.jasny@...>
      To: <ydn-javascript@yahoogroups.com>
      Sent: Thursday, November 29, 2007 1:50 PM
      Subject: [ydn-javascript] Re: DataSource cached response


      > With all respect, I am afraid you didn't really understand my post.
      > The question doesn't relate to HTTP request caching, but rather
      > DataSource in-memory caching. The JSON response to the DataSource
      > query looks like this:
      >
      > {
      > pages: 15,
      > activePage: 3,
      > result: [
      > ...here come the rows to be displayed...
      > ]
      > }
      >
      > Then i define the responseSchema as follows:
      >
      > myDataSource.responseSchema = {
      > resultsList : "result",
      > fields: ["id", "name_given", "name_family]
      > };
      >
      > This way the data source knows which field of the JSON response
      > actually contains the rows. Now what I wanna do is use the pages and
      > activePage fields to generate html paginator. I can override the
      > DataSource.doBeforeCallback method, where I still have access to the
      > full response and it works great. But now data source will only cache
      > the result field, discarding the rest. So the next time, when the
      > rows are pulled from cache, I cannot update the pagination
      > accordingly.
      >
      > I hope this makes it a little more clear what the problem is :-)
      >
      > Kind regards,
      > Vojtech
      >
      > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
      >>
      >> There has been some messages in this list about caching with IE.
      > It seems
      >> IE is quite aggressive with its caching and this is easily
      > noticeable when
      >> you compare it with Firefox. Setting the proper headers on the
      > server side
      >> has often been mentioned as a solution. I don't recall
      > DataSource's caching
      >> mentioned as a problem so far.
      >>
      >> From PHP, I learned to use these headers:
      >>
      >> header('Cache-Control: no-cache, must-revalidate'); // HTTP/
      > 1.1
      >> header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date
      > in the past
      >>
      >> Satyam
      >>
      >>
      >> ----- Original Message -----
      >> From: "vojtech.jasny" <vojtech.jasny@...>
      >> To: <ydn-javascript@yahoogroups.com>
      >> Sent: Wednesday, November 28, 2007 6:48 PM
      >> Subject: [ydn-javascript] DataSource cached response
      >>
      >>
      >> > Hello,
      >> >
      >> > I'm trying set up a DataTable with server-side sorting, paging
      > and
      >> > filtering. I use caching to avoid repeated requests to the same
      > data.
      >> >
      >> > My JSON responses are structured in a way similar to examples at
      > the YUI
      >> > website. I use resultsList parameter to the responseSchema to
      > specify
      >> > where the row data are and then include additional info about
      > how the
      >> > result is paginated alonside that.
      >> >
      >> > This works great for live data source queries. In my overriden
      >> > doBeforeCallback I just extract the pagination data, refresh the
      >> > navigation in the page and then pass on the row data to be
      > displayed by
      >> > the DataTable.
      >> >
      >> > However, when cache is hit, the data source's sendRequest method
      > only
      >> > sends the cached rows to the DataTable and I don't ever get the
      > chance
      >> > to refresh my paginator. Besides, DataSource doesn't even cache
      > the
      >> > additional data that came with the resultsList.
      >> >
      >> > I'm pretty sure I hack around all this by modyfying the caching
      >> > mechanism, but I don't really want that unless there's other
      > way. Has
      >> > any of you ever encountered this? Is there an elegant solution?
      >> >
      >> > Regards,
      >> > Vojtech Jasny
      >> >
      >> >
      >> >
      >> >
      >> > Yahoo! Groups Links
      >> >
      >> >
      >> >
      >> >
      >> >
      >> > --
      >> > No virus found in this incoming message.
      >> > Checked by AVG Free Edition.
      >> > Version: 7.5.503 / Virus Database: 269.16.9/1155 - Release Date:
      >> > 27/11/2007 20:30
      >> >
      >> >
      >>
      >
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      > --
      > No virus found in this incoming message.
      > Checked by AVG Free Edition.
      > Version: 7.5.503 / Virus Database: 269.16.9/1158 - Release Date:
      > 28/11/2007 21:11
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.