How to know optimized resources URI




Wordpress LScache Plugin: How to know optimized resources URI


Hello to all, I would like to know if is there a way to know an optimized resource URI. jQuery, for example: Since LS optimizes jQuery script, in some circumstances I would like to preload it via the response headers: if I can get the jQuery optimized file URI (I saw that the file name is hashed), I can hook to an appropriate WP action and add an header to preload it! Hope that my idea/logic appears clear Thank you! Nicola If you take a look into source code of a requested URL you see a date at the bottom when the current requested URL has been optimized. This date is the time when it is cached and optimized. Regardless of this, preloading matters, but it depends on each user request and on your plugin settings. Preloading a source that is already cached by browser doesnt make sense. The browser has this source already cached, so preloading only matters with the first request. The html preload feature of sources doesnt give any information if a source has already been loaded|send and cached by the browser. This can only be done with http header or http server PUSH. LiteSpeed web server still supports server PUSH and sets a cookie if a source isnt cached|preloaded, so if this cookie isnt set a source will not be preoloaded, if not it is preloaded, but this feature is outside of LiteSpeed cache plugin, so you do have to do define it manually. you can try this function remove_broken_style( $content ) return $content add_filter( litespeed_buffer_after, remove_broken_style, 0) where the $content is the HTML source code that is to be send to browser , it should contains the JS files and CSS files you can search and extract Thank you for your responses. The idea is to add a preload link header to the response header. @CacheCrawler the browser knows if a resources has been already downloaded/cached, so, even if I add a preload header, it would not download the resources again. Or I am missing something? I think that a drawback could be the header size: could it be a problem? @CacheCrawler I saw that filter. Is there somewhere a reference to the resources? Or a LS function that returns the URI of an optimized JS file (for example, for the images I know the LiteSpeed Media webp_url() function)? Otherwise I will scan the page searching for the resources but I am worried about server load? Nicola the browser knows if a resources has been already downloaded/cached, so, even if I add a preload header, it would not download the resources again. Or I am missing something? Basically yes, but the browser doesnt eliminate the preload header/request, so the request will be done in every case. The only difference is that the preloaded source will not be downloaded if it is already in browser cache. To prevent multiple preloads read my post from above.