Plugin Support
qtwrk
(@qtwrk)
Hi,
Are these pages loading exact same CSS/JS files ?
I just did a quick test on StoreFront theme , which in some pages , it loads same generated file , in some pages don’t which they have different JS/CSS
Best regards,
The generated files vary from page to page but only a few files are generated over dozens of pages.
Plugin Support
qtwrk
(@qtwrk)
Hi,
When you see different generated file , please attach to URL this query string to view the original file
/?LSCWP_CTRL=before_optm
and then to see if they are having exact same JS/CSS file
if multiple pages uses same set of CSS/JS , then generated CSS/JS should be same
if pages uses different CSS /JS on each page, then it will generate differente CSS/JS for each pages.
for example
page A , page B , page C use 1.js , 2.js , 3.js , this will generate a a.js
page D uses 1.js 2.js , but no 3.js , then it will get a different generated file , let’s say b.js
if page E uses 1.js and 3.js , but not 2.js , then it will get , let’s say , 3.js
and so on , for CSS as well
Best regards,
Thank you for your response. I think perhaps you did not read my original post or you do not understand what I wrote. I fully and completely understand the concept of how the plugin works.
I want to see different files. My goal is to have a completely separate file generated for every unique URL.
I do not want them to be shared across multiple URL’s even IF those URL’s load the same CSS files.
I don’t care about the JS files because in my configuration I am not combining JS. I use JS HTTP/2 Push so combining them is a waste of resources.
I want seperate CSS files because I am using UNCSS to remove unused CSS from each of them after they are generated by the LS plugin. (I already wrote this above but here it goes…) I cannot rely on this process when the files are shared across multiple URL’s because not all pages, even though they load the same original CSS files, do not utilize all of the rules in the original CSS files. Therefore, if the CSS is stripped of unused CSS based on Page A, then Page B may be missing CSS rules.
Because of this, Page B/C/D/E/F/G and so on need their own generated CSS file so that UNCSS can strip unused CSS from it based on what rules are used in those particular pages.
In short, is there a way to FORCE the LS Cache plugin to generate a new combined CSS file for every unique URL?
Try use /
in Separate CCSS Cache URIs
as it supports partial match.
Thanks, but separate CCSS is not the goal. Seperate CSS is the goal. Additionally, in my instance I am not using CCSS as it is unreliable and bloated. I manually created the CCSS and am including it in the header.php.
Oh sorry my bad. How did you run the uncss node
? I mean, how do you find the page URL for each generated css file? Do you use the mapping data stored in db table litespeed_cssjs
? But there isn’t any source URL recorded.
I am thinking if we give a filter to manipulate the css file name when generating the $filename at https://github.com/litespeedtech/lscache_wp/blob/master/src/optimize.cls.php#L1021-L1025 , will that help?
Or, if you have better idea, please don’t hesitate to let us know. Thanks.
When a unique CSS file is generated for each source URL then the refer
column in that table works as expected.
However, in a hacky case it would not be difficult to derive the hashed file from the last 5 MD5 of the json_encoded SRC + ITEM_TIMESTAMP_PURGE_CSS combination then come at this from another direction. I would do add_action( 'wp', 'interrupt_all_frontend' )
when specific GET vars are present then return the necessary css source list on demand. This would, however, be a pain as it would require running these in advance then saving the results separately somewhere for easy access and constantly testing if option litespeed.optimize.timestamp_purge_css
has changed.
A better solution would be if you update refer
with subsequent source URLs.
Also, would be nice if there was a ON/OFF switch to generate css (or js) for each unique page. Then when ON you could add the uri value in $hash = md5( json_encode( $src ) . $purge_timestamp ) ;
perhaps like $hash = md5( json_encode( $src ) . $uri . $purge_timestamp ) ;
Even better yet… more hooks in your software so people like me can better manipulate/add-to its behavior.
Edit: I saw your last post regarding the filter after I wrote this. Yes, a filter such as that would be helpful. In that situation, I would apply my methodology making the files unique for each URL.
-
This reply was modified 5 years ago by
moongear.
-
This reply was modified 5 years ago by
moongear.
Please try v3.2.3-rc5 https://github.com/litespeedtech/lscache_wp/commit/ed60c62e6f5787d39a6cf55c0e374ee9fff84cd8
I added a filter https://github.com/litespeedtech/lscache_wp/commit/ed60c62e6f5787d39a6cf55c0e374ee9fff84cd8#diff-17436992b3f4fa1bda35dae77aa68954R91. You can take that over to pass in any css you want to replace the default one.
Note: there is a new setting Unique CSS
under CSS settings, you need to turn it on to ignore the file max size limit setting.
I pulled this today and it looks really good. So far it appears to be working as intended.
Thank you so much and I will update if anything changes.
Good to know. Will release v3.2.3 today.
Good morning. So, I don’t think this is working quite right. I am going to create a fork and tinker around with it.
You don’t have to use the filter litespeed_css_serve
. If use that filter, the content has to be generated on the fly.
You can only use the new option Unique CSS. That will give the litespeed_cssjs table one unique CSS per URL. Then you can go through the page using your cron like before to trim the CSS content.
The way you makes this inspired us. For v3.3, we will give a service (similar to CCSS) to provide foreground and background CSS trim to remove unused CSS.
You will be the ONLY service provider that is offering that for WordPress. It is much talked about but nobody is doing it.