Skip to content

Commit

Permalink
Don't cache JS on the backend. Issues with things like Ace editor in
Browse files Browse the repository at this point in the history
plugin lists (random strings in div ID's / JS) and posted data.  Might
work round it with a 'nocache' switch on QS/POST data, but for now, just
don't cache JS on backend.
  • Loading branch information
cheesegrits committed May 1, 2014
1 parent b448bb0 commit 0b15d1c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plugins/system/fabrik/fabrik.php
Expand Up @@ -86,8 +86,9 @@ public function plgSystemFabrik(&$subject, $config)
public static function js()
{
$config = JFactory::getConfig();
$app = JFactory::getApplication();

if ($config->get('caching') == 0)
if ($config->get('caching') == 0 || $app->isAdmin())
{
$script = self::buildJs();
}
Expand All @@ -96,6 +97,14 @@ public static function js()
$uri = JURI::getInstance();
$session = JFactory::getSession();
$uri = $uri->toString(array('path', 'query'));

/*
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
$uri .= serialize($_POST);
}
*/

$file = md5($uri) . '.js';
$folder = JPATH_SITE . '/cache/com_fabrik/js/';

Expand Down

1 comment on commit 0b15d1c

@cheesegrits
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note - the commented out bit that serialized POST data was an attempt to fix the first problem with the Ace editor setup on the backend in conjunction with caching, which is that the Ace setup AJAX calls use POST, not GET. So the $uri is just the vanlilla backed index.php, with no differentiating query string suitable for hashing.

Adding the serialized POST data to the hash works, in that it means the cache picks up the right file ... BUT ... Ace still won't work, because on each call, the actual generated JS for loading Ace includes the random ID/name for the divs. So any cached JS to build an Ace editor doesn't match the actual div ID/name for that page load.

I left the commented code in there, as it would actually be needed for any other POST'ed AJAX calls being cached. I just commented it out, as it became moot when using the bandaid to just not cache JS on the backend.

Please sign in to comment.