I am working on new free compression plugin
and need some help in speeding things up. The process of caching is fairly simple ,
- Get everything in head tag
- Separate the css files, js files, inline css and inline js
- Parse all and minify
- Replace the current head tag contents with new cached one. ( this is trouble )
- Check log for file changes, if there is change , delete the cache for that page and recreate it.
- Scan pages in admin back-end for fast cache creation
Everything works , the pages scan , the compression , css image paths replacement , js and css minify , gzip , I mean everything .
Trouble I have with and to me it seems like it is slowing the rendering down is replaceFiles method https://github.com/youjoomla/jcompress/blob/master/jcompress.php#L567
In order to get the head tag contents. I have to do all of this in
All methods you see in the plugin except
are killed if the cache file exists.
Can anyone take a sec and see if there is something I could do to speed up the replacement of the head contents. And please take a min and test it on your server.
On my local the things are flying. On my live http://stefanstojanovic.com/jcompress/ I see a lag. No bugs , no errors, all cached files created and served. I hope is just my server but I am not sure.
I see a lag on first load , for example here http://stefanstojanovic.com/jcompress3/index.php/breadcrumbs
Next load is 150% faster It "kinda" does make sense since on second load cached css and js is coming from your cache but it should not be such a difference.
Any help is appreciated.
*Update: In meantime I managed to speed it up a bit by only getting the head tag contents instead of the whole body but I still see the lag.
One major difference I also see is between php 5.3 and 5.4 and up. But still no errors on each.