Support

Admin Tools

#14639 combine javascript Joomla 3

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by nicholas on Saturday, 12 January 2013 08:31 CST

DaveOzric

Mandatory information about my setup:

Have I read the related troubleshooter articles above before posting (which pages?)? Yes
Have I searched the tickets before posting? Yes
Have I read the documentation before posting (which pages?)? Yes
Joomla! version: (unknown) 3.0.2
PHP version: (unknown)
MySQL version: (unknown)
Host: (optional, but it helps us help you)
Admin Tools version: 2.4.4

Description of my issue:

I am trying to use combine javascript file in the seo and links but it only works the first time I load the homepage. After that is goes back to not combining. It seems to be having the system cache plugin enabled may be the problem. I do not have this problem with my 2.5 installs.

Thanks

nicholas
Akeeba Staff
Manager

I would agree that the system cache plugin is the issue. You hav to purge your site's cache before enabling the Javascript combination. Moreover, caching can be set to Off, Conservative or Progessive. Conservative caching should work with the plugin. Progressive, I don't think it should work at all.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

DaveOzric

I am not using the site cache, progressive or conservative, they always cause too many problems. I only use the system cache plugin, browser caching option set to off.

Clearing the cache only allows it to load once minified. After that it does not work on page reload. I like to use the system cache if possible and most 2.5 sites it is not a problem and they both work fine together.

Something must of changed in J3 or AT?

Thanks for your help

nicholas
Akeeba Staff
Manager

Looking at the implementation of the System - Cache plugin in Joomla! 2.5 and 3.0, you can't use it with together with Admin Tools' link migration, force HTTPS and CSS/Javascript combination.

In order for any of those features to work, Admin Tools must be the last thing that runs on the onAfterRender Joomla! event (which it makes sure it does). If it's not the last one, other plugins may end up creating wrong links, non-HTTP links or add more CSS and Javascript files.

In order for the System - Cache plugin to work, it also requires that it's the last thing that runs on the onAfterRender Joomla! event so that it can save the page in the file cache and serve it later from the cache.

No, you can't have Admin Tools' plugin run as the second-to-last onAfterRender event handler. Joomla! implements a FIFO event handling queue. You can only add something to the end of the queue, not in any off place (unless you start modifying the Joomla! core).

So, the bottom line is: Admin Tools SEO & Link features are incompatible with the System - Cache plugin.

Why did it work in Joomla! 2.5? Because you didn't test it thoroughly :) You had enabled the "Use browser cache" feature but you only tried accessing your site from the same browser. If you tried accessing the site from a different browser or device you'd see that it would not be loading the combined Javascript files. Just like your Joomla! 3.0 site (where you didn't use the browser cache option) does.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

DaveOzric

First off, I don't quite understand all the technical jargon and don't want to be confrontational but I did state I am NOT using the browser cache in the system cache plugin. It is set to off.

I have tested all the J2.5 sites in IE, Chrome, FF and they all stay minified or combined while accessing the site. Not sure why you don't believe that.

The problem seems to be with Joomla 3. It is combined the first time you load the page then never again after without clearing the cache.

Obviously I do not have a fraction of your knowledge but I can only go by what I am seeing.

Now that you know I am not using the browser cache feature in the system cache is there something that needs to be updated.

Thanks

nicholas
Akeeba Staff
Manager

I am looking at the code in the plugins/system/cache/cache.php under both Joomla! 2.5.8 and 3.0.2. The code is identical. I can actually understand what it does too :) I also understand how my plugin works and how Joomla!'s caching works. Put in layman's terms:

  • The System - Cache plugin looks at the page right before it's sent to the browser and saves it to a file
  • If that file exists, the next time the page loads it will serve the file and will not let the plugins run
  • The System - Admin Tools plugin also needs to take a look at the page right before it's sent to the browser for the features I mentioned in my previous reply to work
  • Due to the way Joomla! works, you can only tell it which is the last plugin to take a look at the page before it's sent to the browser. Admin Tools sets itself as the last plugin to take a look at the page before it's sent to the browser. If it didn't, the features I mentioned wouldn't work at all.
  • Since Joomla!'s System - Cache plugin takes a look at the page before the System - Admin Tools gets a chance to modify the page, Joomla! caches the "wrong" version of the page, i.e. the page before Admin Tools applies its magic.
  • However, the first time you do access the page, Joomla! DOES let all plugins (including Admin Tools) run on the page. This is why you do see the Javascript being combined.
  • On the contrary, on the nest page load, the System - Cache plugin kicks in and serves the saved copy of the page. As you remember, it's the copy of the page without Admin Tools' magic applied, i.e. without the Javascript combined.

I would suggest doing the following test with Joomla! 2.5 and, say, Chrome:

  • Turn on Admin Tools' Javascript combining feature
  • Turn on the System - Cache plugin
  • Clear your browser's cache
  • Visit a page and take a look at its source code. The Javascript is combined.
  • Clear your browser's cache
  • Quit the browser. If you're on a Mac use CMD-Q, don't just close all windows
  • Restart your browser
  • Visit the same page.
  • For good measure, do a forced page reload. It's CTRL-SHIFT-R on Windows and Linux, CMD-SHIFT-R on a Mac.
  • Take a look at the page's source code. The Javascript is not combined.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

DaveOzric

I'm sorry that doesn't appear to make any difference. Viewing a 2.5 site in Chrome and following your step exactly the files are compressed no matter what I try.

This was one of the things I really liked about your extension is it seemed to work well with the native Joomla core.

Don't get me wrong, I just can't duplicate this problem with a J2.5 website. I would be happy to do a screencast showing you all the steps I am performing.

nicholas
Akeeba Staff
Manager

I'm terribly sorry to tell you, but your testing is flawed and you get false results. I actually did install fresh copies of Joomla! 2.5.8 and 3.0.2 on a variety of server configurations. In all cases my testing results were identical in both 2.5.8 and 3.0.2 for the very exact reasons I analysed twice above.

However, I understand why you may have mislead. Page caching DOES NOT come into effect in the following cases:

  • The cache directory is set incorrectly or otherwise unwritable by Joomla!. In this case nothing can be written to the cache and Joomla! ends up regenerating the page in each page load.
  • Debug System is enabled. In this case the System - Cache plugin does not perform any caching to ease debugging the site.
  • If you are logged in the System - Cache plugin does not perform any caching. It only caches pages served to guests.

I have spent 6 hours on this non-issue and I am perfectly sure that my analysis from reading the code is 100% verified by the results I get on different browsers, different Joomla! versions and different server environments. From my end this is a non-issue which has to do with Joomla!'s limitations on the plugin queue API. In fact, I would recommend not using the System - Cache plugin as it is hardcoded to always use disk as the caching medium (slow). If you desperately need to speed up your site I would recommend implementing a CDN. There's a great plugin from NoNumber which works with a plethora of CDNs and makes integrating a CDN with Joomla! virtually effortless. Since CDNs read the data which Joomla! would send to the browser the combined CSS/JS does get cached, without the funky effects of the System - Cache plugin.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

DaveOzric

Thank you for your time and efforts, I very much appreciate the information on CDNs. I have never heard of that but it looks very interesting.

Maybe the combine css/js is better than the cache anyway.

 

nicholas
Akeeba Staff
Manager

You're welcome :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!