0

I am building a WordPress website with an Underscore theme, it is hosted on flywheel. Everytime I make changes to a page, the styling style.css file is not picked up unless I do a hard reload/ clear cache.

Obviously I want it to load on everyone's computer immediately without the need to clear the cache. What is the reason for this? and how can I resolve it?

thanks.

1

If the files are being cached, then whatever caching solution you are using is working! That's why there's a clear caching button available. Typically JS and CSS files will be cached. While you are in development I recommend changing the version of the file being cached. This can be done by updating the wp_enqueue_script (js files) and wp_enqueue_style (css files) functions, typically found in functions.php. Taken from the codex:

wp_enqueue_style( string $handle, string $src = '', array $deps = array(), string|bool|null $ver = false, string $media = 'all' )

$ver: (string|bool|null) (Optional) String specifying stylesheet version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added. Default value: false

In summary, find the function above in your functions.php file, and change the 4th parameter ($ver) to a string. Something like "0.1", and then each time you save a new style.css file, update the string to "0.2" and so forth. That way, the browser will always request a new file from the server. This is a great solution during development.

You never specified what caching plugin you are using, or if it's something Flywheel does it for you, but you should have setting you can change so that the cache is cleared more often.

0

Could be related to changing the expiration period by modifing .htaccess.

For example my .htaccess has access 1 month for this action, and your could be like below:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 60 seconds"
ExpiresDefault "access 1 month"
</IfModule>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.