Multisite – prevent duplicate browser cache in sub site?
-
Hi,
I’m responsible for maintaining a large multisite installation (200+ sub sites) for a single organization. I have the same theme applied to virtually all of the sub-sites – with a few child theme variations of it.In the interest of reducing bandwidth and increasing load speeds I’m wondering how to prevent a visitors browser from loading/caching duplicate css/js/image files when visiting multiple sites that have the same theme – AND at the same time not break a child themes’ ability to override the parent version of those same files.
I’ve looked through the forum and elsewhere but haven’t found an existing WP function to do this- I’m hoping there’s an easy way to do this without writing a ton of custom code.
I already know how to load the css/js etc from the main theme folder without a subsite url – by hard coding part of it.
The following works for me:
<br /> <link rel="stylesheet" href="<?php echo network_site_url(); ?>wp-content/themes/themename/something.css" type="text/css" ><br />
This results in a style tag loading “example.com/wp-content/themes/thetheme/something.css” – instead of “example.com/site2x/wp-content/themes/thetheme/something.css”
Ideally I’d like to always queue files with an url like this:
“example.com/wp-content/themes/thetheme/something.css”
But then if there’s a child theme version of that file – to instead queue that:
“example.com/wp-content/themes/thetheme-childver/something.css”I’ve got an idea to do this by making my own function to return the appropriate file url – and if a site has a child theme, check if there is a duplicate file by using php “file_exists();” … I’m hoping there’s a faster way.
BTW – I’m currently queueing all the css and js files the main theme theme functions.php.
I hope this makes sense – any help is greatly appreciated.
- The topic ‘Multisite – prevent duplicate browser cache in sub site?’ is closed to new replies.