The code detects asset files in the html output you are about to send and sends push headers for those assets ahead of the html.
It does not care whether that html output is for mobiles or desktops and it does not detect image resolutions.
Code: Select all
$regexp = '#(data-src|src|src2|href)="([^"]+\.('.implode('|',$ext).')(\?[^"]+)?)"#';
In words, any asset starting with
data-src=,
src=,
src2= or
href= and with extensions
.css,
.js,
.woff,
.woff2,
.ttf,
.jpg,
.webp,
.png or
.mp3
(you can add or remove any if you wish in that regex)
That will produce records like:
Code: Select all
[0] => Array
(
[0] => href="catalog/view/javascript/bootstrap/css/bootstrap.min.t1535802328.css"
[1] => href
[2] => catalog/view/javascript/bootstrap/css/bootstrap.min.t1535802328.css
[3] => css
)
Code: Select all
[6] => Array
(
[0] => src="catalog/view/javascript/jquery/jquery-2.1.1.min.js"
[1] => src
[2] => catalog/view/javascript/jquery/jquery-2.1.1.min.js
[3] => js
)
Code: Select all
[66] => Array
(
[0] => src="image/ci/ca/pi/65/659/659_L1-Prehnite-Pendant-in-18-Carat-White-Gold-120x90.webp"
[1] => src
[2] => image/ci/ca/pi/65/659/659_L1-Prehnite-Pendant-in-18-Carat-White-Gold-120x90.webp
[3] => webp
)
etc.
There is no detection on resolution.
Ones detected, you can filter those assets on the content of the filename if it contains the resolution in case of images.
The only assets the code cannot detect are those not referenced in your html output but are referenced inside asset files.
For example, fontawesome references font files inside its css files, the code detects the css file but not the font files inside, those the code cannot see and those you should define statically.
I see your output uses
srcset=, perhaps add that to the regex and see if it takes those assets as well.
or try a regex for images like: