• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

style.css: how to version to avoid browser cache (when changed)

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › style.css: how to version to avoid browser cache (when changed)

This topic is: not resolved

Tagged: browser, cache, css, style.css, version

  • This topic has 2 replies, 2 voices, and was last updated 7 years, 8 months ago by DanielMT.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • May 30, 2018 at 9:52 am #220388
    DanielMT
    Participant

    Hi,

    When making changes to the style.css file, you're forced to refresh the browser to reflect the updates done.

    A way to avoid that is to add a "version" to the style.css file on the html code.

    I've found a snippet to do that (added in functions.php file):

    wp_enqueue_style( 'global', get_stylesheet_directory_uri() . '/style.css', array(), filemtime(get_stylesheet_directory() . '/style.css'))

    That will create a line of code like the following (with "ver" parameter):

    ...wp-content/themes/enterprise-pro/style.css?ver=1527693949

    That will force the browser to reload the new file, each time the file is changed.

    However, genesis will add a similar line of code, like this one:

    ...wp-content/themes/enterprise-pro/style.css?ver=2.1.1

    How can I avoid that? I just want the "versioned" line of code to appear in the source code.

    Thanks.

    June 1, 2018 at 6:43 am #220450
    Victor Font
    Moderator

    I generally turn caching off when I'm developing. Holding the shift key when you reload a page in the browser forces the style sheet to reload.

    You can try changing the child theme version number in functions.php and the style sheet version number in the comment area at the top of the style sheet.

    Another method I use is entirely in PHP. I enable WordPress Debug and if enabled, use the style sheet's time stamp as the version number. Every time the style sheet is saved, it automatically counts as a new version.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    June 1, 2018 at 6:46 am #220451
    DanielMT
    Participant

    Hi,

    The developing process is not a problem. The problem is when it's a production site, and you have a customer that doesn't know how to clear the browser's cache.

    Digging I've found the PHP solution you mention. Now I version the style.css file with it's timestamp, as you mention.

    Thanks.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble