Surely the approach to CSS and JS caching is all backward in ctools at the moment?

Currently the server is trying to keep track of the css and js files sent to the client, and only send ones it doesn't already have. Putting the data in a really fragile cache though, is not a good idea. Try adding a node with a ctools modal, then click another ajax link on the same page, for example.

Isn't the client better placed to know what CSS and JS files it has been sent? Rather than store the array of sent CSS and JS file on the server in a cache, can't we send that data over to the client, and let the client decide if it should be adding CSS and JS on an AJAX request.

Trying to do this sort of AJAX loading is very cool mind you, just this belongs on the client, not the server.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

I'm actually generally in favor of this, but I think the issue is that we were having trouble figuring out how to communicate this data. I would welcome a patch that does this, becuase honestly I don't like exploding the cache with this data and I think it should be embedded as a .js command in the footer or something.

DeFr’s picture

Status: Active » Needs review
FileSize
7.6 KB

There you go.

Attached patch adds some CTools settings to the page footer to keep track of the loaded CSS / JS files, and fills the Drupal.CTools.AJAX.{scripts,css} variables with them in the behaviors. This allows to get rid of the fragile server side caching.

Tested with both JS and CSS aggregation on, seems to work fine.

merlinofchaos’s picture

Status: Needs review » Fixed

I am ecstatic that you got this working. This is committed and I'm recommending that core use the same technique in D7.

Scott Reynolds’s picture

Ahh this is so much better :-D but I think this is an error

edit:I was wrong no error there.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kcathebat’s picture

Sorry, new to drupal, I was just wondering how do I install this patch?

Thanks
Kraig

DeFr’s picture

@kcathebat: This patch has been already included in CTools, so you just have to use a version that has been released after July 5, 2010, which means CTools >= 6.x-1.7