Hello,
Just like others (search the forums/Google) I was annoyed by the seemingly slow page loading in the Zabbix web interface. So I went out to investigate.
After having already tuned my Postgres database and installed a PHP opcode cacher (APC) page loading was still slow. I noticed however that my browser makes a lot of requests for objects (~34, css files, images, javascript files) on EVERY page load and that some of those objects are pretty big. For example jsLoader.php (a Javascript file containing the Prototype framework) is ~350kB.
So I enabled Gzip compression in Nginx, that brought the size of most objects down tremendously (jsLoader.php was now only 90kB).
I also wanted to take use of client side caching, so that the browser doesn't requests all the static files on the page again and again on every page load:
That seemed to mostly work as expected. However, I noticed that my browser would still make GET requests for all objects from time to time, to revalidate all the objects on the page (using the If-Modified-Since header, to which the server responds with a 304 Not Modified). Thus introducing again the unnecessary overhead and roundtrips for HTTP requests for 34 objects. Even though I told it to cache all those objects...
After some looking around, this seemed to be triggered when the graph and status pages reload automatically. It turns out that in js/main.js, the page is reloaded by doing (line 41):
Apparently this forces the browser to not only reload the current page, but also to revalidate ALL the objects on the page (it sets Cache-Control: max-age=0). Thus making 34 GET requests again, instead of using the objects already cached. That's horribly inefficient!!
I saw this behavior in FF and IE (Opera however seems to respect the cache or not respect the reload call, depending on how you look at it).
To have it work 'properly' in FF and IE as well, I replaced that line by:
And, bazinga! The refresh only triggered GETs for about 4 objects instead of 34. Reload times of, for example, the trigger status page (with no triggers active and first visit time of +2 seconds) went down from ~1,50 seconds to only ~0,90 seconds!!
IMHO, this is a big improvement. Certainly considering that my numbers are for local 100Mbps LAN! Relative improvements over Internet connections will be even bigger!
Also when I had many automatically refreshing pages opened simultanously, I would notice pages getting stuck before or taking a really long time to reload (minutes!). I did not notice this behaviour anymore after this fix!
The load on the webserver will also be a lot lighter, especially if you have many people looking at many pages at the same time!
I didn't notice any negative side effects yet. The status pages or graphs themselves get updated properly, since they aren't cached in the first place. Feel free to test yourself, the 'patch' is simple
@devs:
I noticed the reload call being used in warning.php as well. Maybe improvements are possible there as well?
Is there an official path I need to take to submit this as a patch or can you guys take it from here?
Enjoying Zabbix again,
Hopla
Just like others (search the forums/Google) I was annoyed by the seemingly slow page loading in the Zabbix web interface. So I went out to investigate.
After having already tuned my Postgres database and installed a PHP opcode cacher (APC) page loading was still slow. I noticed however that my browser makes a lot of requests for objects (~34, css files, images, javascript files) on EVERY page load and that some of those objects are pretty big. For example jsLoader.php (a Javascript file containing the Prototype framework) is ~350kB.
So I enabled Gzip compression in Nginx, that brought the size of most objects down tremendously (jsLoader.php was now only 90kB).
Code:
gzip on; gzip_types text/css application/x-javascript text/javascript application/json;
Code:
location ~* \.(jpg|jpeg|png|gif|css|js)$ { expires 30d; }
After some looking around, this seemed to be triggered when the graph and status pages reload automatically. It turns out that in js/main.js, the page is reloaded by doing (line 41):
Code:
location.reload();
I saw this behavior in FF and IE (Opera however seems to respect the cache or not respect the reload call, depending on how you look at it).
To have it work 'properly' in FF and IE as well, I replaced that line by:
Code:
window.location.href = window.location.href;
IMHO, this is a big improvement. Certainly considering that my numbers are for local 100Mbps LAN! Relative improvements over Internet connections will be even bigger!
Also when I had many automatically refreshing pages opened simultanously, I would notice pages getting stuck before or taking a really long time to reload (minutes!). I did not notice this behaviour anymore after this fix!
The load on the webserver will also be a lot lighter, especially if you have many people looking at many pages at the same time!
I didn't notice any negative side effects yet. The status pages or graphs themselves get updated properly, since they aren't cached in the first place. Feel free to test yourself, the 'patch' is simple

@devs:
I noticed the reload call being used in warning.php as well. Maybe improvements are possible there as well?
Is there an official path I need to take to submit this as a patch or can you guys take it from here?

Enjoying Zabbix again,
Hopla
Comment