› Rooms › Site Optimization/Hosting › LSCache and Divi dynamic CSS issues solved
- This topic has 18 replies, 7 voices, and was last updated 1 year, 9 months ago by
Lynne Guistic.
-
-
30 August 2021 at 10:20 pm #996::
Anyone using LSCache the below snippet will address issues caused by Divi’s dynamic css calculation process. Without this snippet you can expect to experience issues.
What will happen when you use this:
* Page load one will be set to no-cache
* Page load two will be a cache miss
* Page load three will be a cache hitWhat will happen if you don’t use it:
* Page load one will be a miss
* Page load two will be a hit (but Divi’s dynamic css will be the same as page load one… which will be incorrect as it changes)add_action( ‘send_headers’, ‘dsl_check_cache_control_constant’ );
function dsl_check_cache_control_constant() {
if ( defined( ‘DONOTCACHEPAGE’ ) && DONOTCACHEPAGE ) {
// set LS Cache Control Header to no-cache
do_action( ‘litespeed_control_set_nocache’, ‘nocache due to Divi static file creation’ );
}
}-
This topic was modified 1 year, 9 months ago by
Terry Hale.
-
This topic was modified 1 year, 9 months ago by
-
31 August 2021 at 4:01 am #1020
-
31 August 2021 at 4:04 am #1023::
After any save/update, page load one and page load two are different as Divi calculates dynamic css on page load one and then applies it on page load two.
LSCache (and likely some other caching plugins) cache page load one, thus you do not see the updated css on page load two.
This snippet will address that issue.-
31 August 2021 at 4:05 am #1024::
so you Are saying, just so i get it, I visit a website the First time, it shows me the website.
You as website owner, changes something on the website the Day after i First visited the website, and of cource you clear all caches, in order to Update everything.
The following Day, i visit your website Again, so i Will see the same thing as i Saw When i visited your website for the first time or Will i see your updated website?
-
31 August 2021 at 4:06 am #1025::
The website will not look different, but it will perform differently…
Assuming you have either just saved/updated a page, or just cleared out the Divi static css files, when you load a page for the first time, it loads a lot of the css inline in the bottom of the body. At this point it calculates what css can be loaded late, what css is critical and a few other things but it doesn’t use that css “correctly” on the first page load because it doesn’t have the information until after the page is loaded.
The second (and subsequent) times you load the page, it uses that information to load the page a bit differently – using critical css in the head, late css… later, static files linked etc.
If a plugin or server cache, caches the page on the first page load… as you can imagine, it will just keep loading the page with all the css inline at the end of the body. It will still look the same, but you will likely have CLS issues and the page will also not perform as well as it could.
If you want to see what’s happening, just clear the static css files, load a page and take a copy of the html. Then load the page again and compare the html – you will see it’s quite different and there are additional css files that were not present on the first page load.
-
-
-
-
31 August 2021 at 4:11 am #1029::
I’m not sure I understood. When I updated my sites with the new version of Divi, I had display problems. I cleared the LiteSpeed cache but it didn’t change anything. Divi support told me to disable “Dynamic CSS”. What should I do about your recommendation? Reactivate Divi’s “Dynamic CSS” and add this code, is that right? Where should I add this code in this case? Thank you
-
31 August 2021 at 4:17 am #1041::
Seems like a core testing issue wasn’t investigated or simply ignored. There is no way in the world that Divi’s is not going to be used on sites with major caching plugin/systems. How many users are going to be left chasing their tails, going round and round in circles trying to fix something that many will have no idea how to fix! It will be interesting to see if ET confirm they’ve tested it with all the other major players or not.
-
31 August 2021 at 4:18 am #1042
-
31 August 2021 at 4:20 am #1043
-
31 August 2021 at 4:21 am #1045
-
31 August 2021 at 4:21 am #1046::
I’ve never used that plugin since I routinely set up all my sites to run a basic child theme. However, I looked at the snippet plugin and it appears that it will work – “Code Snippets is an easy, clean and simple way to run PHP code snippets on your site. It removes the need to add custom snippets to your theme’s functions.php file.”
-
-
-
-
31 August 2021 at 4:24 am #1050
-
- You must be logged in to reply to this topic.