|
How to cache an ajax request?
|
|
2nd June, 18:04
(This post was last modified: 2nd June 18:05 by ad209.)
Post: #1
|
|||
|
|||
|
How to cache an ajax request?
Hi there,
I was wondering if it's possible to cache an ajax request so that the webservice isn't hit each time you mouseover the same element. I know in jquery there is a feature that allows this through their ajax options providing a good performance gain. At the moment everytime you roll over the same tooltip element it makes a request. How can I go about setting the same option using qTip? Regards DotnetShadow |
|||
|
3rd June, 03:55
Post: #2
|
|||
|
|||
|
How to cache an ajax request?
If my understanding of how jQuery's internal AJAX functionality works is correct, caching should be done by the library itself automatically without any prior settings.
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
3rd June, 11:57
Post: #3
|
|||
|
|||
How to cache an ajax request?
craig Wrote:If my understanding of how jQuery's internal AJAX functionality works is correct, caching should be done by the library itself automatically without any prior settings. I've setup a test page which shows this isn't happening along with my other errors that I have reported: http://74.212.223.45/qTipSample/admin/Default.aspx Hope this helps DotnetShadow |
|||
|
3rd June, 12:22
Post: #4
|
|||
|
|||
|
How to cache an ajax request?
Nice demo dotnewshadow, very informative.
Regarding the caching issue, this isn't a case where caching can be used, since the page you're requesting is always changing. Caching only works on pages with static content, such as HTML pages or static text files. What are you trying to accomplish which requires the data caching? Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
3rd June, 13:49
(This post was last modified: 3rd June 14:45 by ad209.)
Post: #5
|
|||
|
|||
How to cache an ajax request?
craig Wrote:Nice demo dotnewshadow, very informative. Hi Craig, Thanks for getting back to me, I understand what you mean with dynamic pages but even if I produce the same response it still doesn't cache it. I've implemented this in the past using another tooltip plugin and it would cache the result. But for some reason using your plugin it doesn't cache the result? What I'm trying to achieve is to make unnecessary requests. The whole thing about caching the result is the next time it makes the same request it should just returned the cached version, so Im not sure what is happening there. This was the tooltip plugin I had been using - Cluetip: If you lok at Example 2: http://plugins.learningjquery.com/cluetip/demo/ you can see through firebug that the ajax request is only made once then cached Maybe you can get an idea how caching got implemented there? I think they just set up a variable that holds the ajax request response so if it exists then show the contents if not then make the ajax request. http://github.com/kswedberg/jquery-cluet...cluetip.js Regards Dotnetshadow |
|||
|
5th June, 03:53
Post: #6
|
|||
|
|||
|
How to cache an ajax request?
Dotnetshadow,
Looking over the code I can't see how it's being done any differently. Are you sure it's caching it and instead only retrieving the content once? Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
9th June, 11:21
Post: #7
|
|||
|
|||
How to cache an ajax request?
craig Wrote:Dotnetshadow, Yeah I looked deeper into the code and looks like the code attaches the result to the element using jquery data api i.e div.data(). Then the next time you hover over the element it checks if the data is present and if so it returns it, else it does the ajax request. So basically you could implement the same trick provide perhaps an option whether you want this feature and basically on first ajax request populate the element with the result etc What do you think about that? Regards Dotnetshadow |
|||
|
10th June, 00:04
Post: #8
|
|||
|
|||
|
How to cache an ajax request?
Dotnewshadow, thanks for looking further into this. I'm 50-50 as to whether this should be a base-level feature or whether it should be implemented individually via the API...
I can however see that a majority of users may find this useful in some way or another, but in heinsight it seems like this could be accomplishe simply by using a different API callback i.e. onRender rather than onShow? I'll have a think, but in the mean time: Would you the users, find this kind of feature useful? Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
10th June, 10:28
Post: #9
|
|||
|
|||
How to cache an ajax request?
craig Wrote:Dotnewshadow, thanks for looking further into this. I'm 50-50 as to whether this should be a base-level feature or whether it should be implemented individually via the API... Thanks Craig for looking into this, in the meantime with the onRender method could you provide a quick example of what would be needed to accomplish this task? DotnetShadow |
|||
|
13th June, 06:03
Post: #10
|
|||
|
|||
|
How to cache an ajax request?
Dotnetshadow,
Basically the code is indetical to what you ahve now, except that beforeShow within the api object becomes onRender e.g.:
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
17th June, 12:29
(This post was last modified: 17th June 12:44 by ad209.)
Post: #11
|
||||
|
||||
How to cache an ajax request?
craig Wrote:Dotnetshadow, Hi there I noticed that in your latest branch version you have introduced a new pre-fetch feature which sounds great. I just wanted to know does that mean if you have 1000 tips on a page it will try and pre-fetch each one? The problem I see with this is that there could be a case when a page loads and a user doesn't roll over any tooltips so all the pre-fetching is a waste, but having the ability to cache the tooltip once you have rolled over it that would be very handy, perhaps we need to options one to suggest whether to pre-fetch and one for caching only. Also how do you I use the prefetch option using beforeShow function? Currently I'm using this function (will prefetch and cache work with this?):
Regards Dotnetshadow |
||||
|
20th June, 04:22
Post: #12
|
|||
|
|||
|
How to cache an ajax request?
Hi dotnewshadow,
Sorry it's taken so long to reply, busy preparing for the 1.0 release with a new rounded corner engine . Any who, the prefetch functionality is implemented as a pre-cursor to tooltip rendering, which means that sadly it can't be used using the beforeShow event like you need. You can however declare the URL and prefetch within the initial options to prefetch then set it manually like you are doing now? That may work. Get back to me if you require any more assistance.
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
20th June, 22:08
Post: #13
|
|||
|
|||
|
How to cache an ajax request?
Thanks for getting back to me,
I think earlier you mentioned to use onRender method to cache the data, do you mean just set up an array or something and just store the results in that? and then each time I check the array before calling the ajax method? Dotnetshadow |
|||
|
20th June, 23:00
Post: #14
|
|||
|
|||
|
How to cache an ajax request?
The onRender solution should work fine for you. Basically it just involves replacing beforeShow with onRender in your API callbacks like so:
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
21st June, 14:42
Post: #15
|
|||
|
|||
|
How to cache an ajax request?
I'll give this a try, it will be interesting to see if the result does cache or if I have to manually create a caching mechanism similar to the $(element).data() idea we discussed earlier
Dotnetshadow |
|||
|
23rd November, 03:11
Post: #16
|
|||
|
|||
|
How to cache an ajax request?
Hi Craig, hi Dotnetshadow,
Me too, I would like to see a feature where you can the results of requests cached. Any news on this? Thanks, hbf |
|||
|
23rd November, 10:25
Post: #17
|
|||
|
|||
|
How to cache an ajax request?
Hi hbf,
There is currently a new content.url.once option in the newest branch revisions, but they are highly unstable at the moment with some quite heavy changes to the source code. If you want you can take a look through the branch revisions and pick out the revision the option was added: http://bazaar.launchpad.net/~craig.craig..._revid=176 Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
« Next Oldest | Next Newest »
|
| Possibly Related Threads... | |||||
| Thread: | Author | Replies: | Views: | Last Post | |
| Calling qtip from an ajax request | hfidgen | 1 | 375 |
30th November 11:26 Last Post: Craig |
|
| Ajax Request | grahammills | 1 | 304 |
31st July 00:46 Last Post: Craig |
|
| Showing tips on load, destroying on ajax request begin, and recreating | mleduc | 2 | 662 |
20th May 05:16 Last Post: Craig |
|
| api.hide() after an ajax request | gostbuster | 9 | 691 |
6th May 17:32 Last Post: gostbuster |
|

Search
Member List
Calendar
Help




. Any who, the prefetch functionality is implemented as a pre-cursor to tooltip rendering, which means that sadly it can't be used using the beforeShow event like you need. You can however declare the URL and prefetch within the initial options to prefetch then set it manually like you are doing now? That may work. Get back to me if you require any more assistance.