Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1220607

    We have having issues with our sites clearing local cache when using child themes, which we ALWAYS do. The problem arises when we change style.css in the child theme, those changes are NOT noticed by all browsers, particularly bad with Chrome on Mac. Our host is WP Engine.

    We noticed that Chrome on Mac says the following by default for telling the browser how long this file should last before it checks for a new copy:

    cache-control: public, max-age=31536000

    That is 1 year…

    Now when you upgrade the parent theme, the version changes and WordPress dynamically changes the filename for style.css by appending the latest version #…however, if we make changes to the style.css in the child (which we ALWAYS do), the version # of the parent does NOT change, so the cache control does not change, and browsers have no reason to check for a new copy.

    This is causing us to tell clients to manually reload the browser (pls press shift + refresh) and they always have a valid point – no one is going to tell all their site visitors to do that…

    So we worked with WPE to find out where these default settings are coming from, and they gave us the attached report (in private content).

    Can you help us understand why the theme is telling browsers NOT to look at files again for a year or until the parent theme is upgraded when the use of child themes is so prevalent?

    Thanks!

    #1220799

    Hey Kyle,

    Thanks for the screenshot, as far as I can see there are only backend files referenced in there. How would that affect the front end of your site? We can’t do anything about local cache on your clients machines unfortunately, but by default I think local cache expires within a week or so.

    Best regards,
    Rikard

    #1220920

    OK – maybe you can help me understand how style.css in the child theme is inheriting this cache control setting? (see new image)

    I’ve asked WPEngine to help us understand if their caching is doing something magical… they’ve confirmed the htacess is very plain / generic and are trying to confirm if style.css in the child theme is inheriting from parent or other files from Enfold or somewhere else.

    This is all new to me so I’m just trying to be an honest Quarterback and facilitate the troubleshooting.

    Thanks

    #1220945

    Here is an update from WPE – they are about to push to staging for resting as their staging can rule out their caching:

    Thank you for taking the time to chat with WP Engine Support today! I reviewed your chat and see that you had some questions regarding the headers cache being set to one year for the site (xxxxxxx).

    Based on what we are seeing on our end, there appears to be something configured which is making the “public” header on the file and we most often see this with a theme.

    Would it be possible for our Support team to push your site to staging to test with a different theme to try to narrow this down further?

    Once we have your confirmation, we can review and investigate this further.

    If there is anything we can help with in the meantime, please let us know! We are here for you anytime, day or night.

    As soon as we hear back from WPE we will update you.

    #1222712

    So WP Engine has taken responsibility for this after pointing us in your direction initially…helps to get thru to 3rd line support :D

    It appears WPE sets the cache control for all static files to 1 year. Here is their reply:

    According to my notes – it looks like your main question is regarding why the theme (parent and child) style.css is reflecting a 1 year cache-control header:

    cache-control: public, max-age=31536000
    I can confirm that all static files on our platform, including css, js, images like jpg and png, and many others all are set to include a cache-control header of 1 year. So while the file comes from the theme, our server is what’s setting the cache length for that file in a user’s browser, and the 1 year timeframe is default!

    Did you have questions about adjusting that timeframe or altering anything about cache-control headers, or were you just checking to confirm if that 1 year timeframe was correct?

    I replied asking ‘I’d like to know why you set these to 1 year and how to override that?’ and they replied:

    So these would be set at Nginx level: The default rule that is in place on the NGINX config is as follows. This is in place on all installs across our platform and would be the default rule which is set as it is viewed as the best cache control for performance purposes.

    location ~* ^.+\.(?:jpe?g|gif|png|css|js|ico|zip|7z|tgz|gz|rar|bz2|do[ct][mx]?|xl[ast][bmx]?|exe|pdf|p[op][ast][mx]?|sld[xm]?|thmx?|txt|tar|midi?|wav|bmp|rtf|avi|mp\d|mpg|iso|mov|djvu|dmg|flac|r70|mdf|chm|sisx|sis|flv|thm|bin|swf|cert|otf|ttf|eot|svgx?|woff2?|jar|class|log|web[pma]|ogv)$ {
    ### MU Rules (Static) ###(none)###
    if_modified_since before;
    add_header Cache-Control “public, max-age=31536000”;
    add_header Vary “Accept-Encoding”;
    add_header Access-Control-Allow-Origin *;
    }

    We can alter this for you to a different max age if you wish. just let us know and we’ll be happy to help.

    I’m closing the case with both parties now as we have a better understanding of the issue and have asked WPE NOT to set our cache control to 1 year as the style.css is obviously not a static file…

    I appreciate your cooperation and patience on this.

    #1222951

    Hi,

    Thank you for these updates. Glad to know that it’s fixed. We’ll close the thread now, but please don’t hesitate to open another if you need anything else.

    Have a nice day ahead.

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘default parent theme caching style.css is max age = 1 year by default’ is closed to new replies.