yireo-joomla / pkg_scriptmerge

GNU General Public License v3.0
7 stars 10 forks source link

Link Preload Headers have issues #24

Closed robobenklein closed 7 years ago

robobenklein commented 7 years ago

There seems to be a small issue in the preload header generation, an extra / is added after the domain, causing the browser to treat the same merged CSS as two different sources.

In the HTTP Header: image

But then in the page's html: image

The extra / in the preload header causes Chrome to preload it, but then re-download since it thinks the url in the html is different, hence it also gives this warning: image

I think this shouldn't be too hard of a fix right?

robobenklein commented 7 years ago

There seems to be yet another problem, this time involving the URL-encoding or escaping of the ampersands in the URL sent in the Link Preload header:

I get a preload like https://323.robosane.net/component/scriptmerge/?format=raw&tmpl=component&type=css&app=0&version=1&files=JEZwbHVn

Notice the & things, which make chrome do this: image (Obviously they shouldn't be escaped there...)

And then Chrome has to send another request with the correct url options when it gets to the html-contained link: image

So the preload header didn't really do it's job here...

I think the problem is the auto-encoding done by header, probably here? https://github.com/yireo/pkg_scriptmerge/blob/96310a10b681f8cfd29f842f3750ac872478a0fb/source/plugins/system/scriptmerge/scriptmerge.php#L692

Does the header function have an option not to replace the ampersands?

robobenklein commented 7 years ago

Found a solution: http://php.net/manual/en/function.htmlspecialchars-decode.php

https://github.com/yireo/pkg_scriptmerge/pull/25 should fix this.

robobenklein commented 7 years ago

Fixed in https://github.com/yireo/pkg_scriptmerge/pull/25#issuecomment-332800349