BB Caching absolute file references

I’m seeing issues with some images (most appear to be in row settings) placed in BB cache that don’t get pushed up to the CDN.

I’ll send a private followup for the specifics.

[Content Hidden]

Hey Doug,

I’ve already assigned another member of the team to check on this. Thanks for the heads up!

Ben

Hey Doug,

Thanks for the detailed info!

Unfortunately, we have to store absolute paths in the CSS/JS cache since there are cases where relying on the relative path won’t work. They are edge cases, but if we don’t support them, images won’t show on sites with unique configurations.

Additionally, it’s WordPress itself that’s giving us these absolute URLs when you select a photo, so this is something that affects other plugins as well.

I know that WPE is rewriting URLs in the HTML, and that we can’t expect them to rewrite URLs in our cache. However, we did recently implement a filter that might help with this.

I haven’t tested it, but this should rewrite the URLs in our cache to use WPE’s CDN. Go ahead and give this a shot, clear the BB cache and let me know if it works.

function fl_builder_rewrite_cdn_urls( $css ) {
	    return str_ireplace( 'sensiblemystic.com', '1u3p3qzf26gy1vo33fisw914-wpengine.netdna-ssl.com', $css );
}
	
add_filter( 'fl_builder_render_css', 'fl_builder_rewrite_cdn_urls' );

Thanks!
Justin

Justin,

I pasted the code into the Child theme functions.php file and the two images are still showing up with their absolute URLs in the BB cache and on tests via webpagetest.org

So some images are not pulling from the CDN.

Hey Doug,

Can you send me a link to the page in question?

Thanks,
Justin

Justin, Oops. It’s working ok. I just needed to flush “Autoptimize” cache.

Thanks.
Doug

Awesome, Doug! Glad to hear it’s working :slight_smile:

Is this a working solution for sites hosted on WP Engine?

I am also seeing images not on their CDN.

Thanks!

I had forgotten about this. It looks like there are still some issues with WP Engine/MaxCDN and the Photo Module with BB plugin/theme. It might have to do with WordPress 4.4 and the changes they made to how responsive images are displayed.

When I run a page with images using the Photo Module within a Column on webpagetest.org, the first time the image is pulled directly from the site. After the DOM is loaded, the image shows again referenced to the CDN.

I talked with WPE today and they said it’s possibly due the “srcset” not referencing the CDN. Here’s the way the source code looks.

img class=“fl-photo-img” src=“https://1u3p3qzf26gy1vo33fisw914-wpengine.netdna-ssl.com/wp-content/uploads/2015/08/oracle-cards-homepage.jpg” alt=“Oracle Cards” itemprop=“image” srcset=“https://sensiblemystic.com/wp-content/uploads/2015/08/oracle-cards-homepage-330x186.jpg 330w,https://sensiblemystic.com/wp-content/uploads/2015/08/oracle-cards-homepage.jpg 720w” sizes="(max-width: 720px) 100vw, 720px" /

Hope someone can shed some light on this.

Thanks.
Doug

Doug, this won’t solve your problem but you may want to setup a cname for cdn.sensiblemystic.com and have it point to 1u3p3qzf26gy1vo33fisw914-wpengine.netdna-ssl.com

About 8 hours after you do this, open a support request and tell them to change your cdn to cdn.sensiblemystic.com

There may be some SEO benefit to keeping your images on the same domain.

Richard,

Thanks for following up. I like the idea of setting the CDN up this way, but I’ve purchased the Standard SSL cert through WP Engine and it only covers “sensiblemystic.com” and “www.sensiblemystic.com”. I’d have to pay for an extra Standard SSL cert to cover “cdn.sensiblemystic.com” or convert the current SSL cert to a Wildcard SSL cert.

I think I’ll look into some third party SSL certs.

Thanks.
Doug

Hey Doug,

I’m pretty sure the issue is with the new srcset attribute. Are they not replacing URLs with the CDN URL there? If not, they should add that to their CDN routines. Let me know what they say about that if you can.

Justin