Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#15005 closed defect (bug) (wontfix)

Network theme assets are not efficiently cached

Reported by: berniecode's profile berniecode Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.1
Component: Multisite Keywords:
Focuses: Cc:

Description

In Wordpress 3, when you install a theme and activate it as a network theme, all sites share one set of theme files on disk. However, each site accesses the files through a different URL.

For example, if you have two sites, sitea and siteb, using a subfolder install and both using the theme "my-theme", the theme files will be accessed through:

http://example.com/sitea/wp-content/themes/my-theme/style.css
and
http ://example.com/siteb/wp-content/themes/my-theme/style.css

Both these URLs point to the same file through URL rewriting, but the browser loads and caches them each separately so when navigating between sites, the assets loaded on one site are not reused from the cache for the next site.

The correct behaviour would be for each site to have a stylesheet loaded from

http://example.com/wp-content/themes/my-theme/style.css

Workaround:

I have fixed this issue on my own site with a filter:

add_filter('theme_root_uri', 'alter_theme_root_uri');
function alter_theme_root_uri($theme_root_uri) {
    // replace
    //     http://example.com/sitename/wp-content/themes
    // with
    //     http://example.com/wp-content/themes
    return preg_replace('#/[\w-]+/(wp-content/themes)#', '/\1', $theme_root_uri);
}

Change History (2)

#1 @Denis-de-Bernardy
13 years ago

Won't the suggestion introduce issues in theme assets that are dynamic or user-specific?

#2 @PeteMall
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.