-
AuthorPosts
-
March 9, 2015 at 5:53 pm #408292
Hi,
I know it’s a local caching issue, but I’m wondering if there are any workarounds for this.
I frequently (often several times a day) modify my custom.css file. Unfortunately, many people keep telling me they see things differently, but it always turns out it’s because they just need to do a CTRL+R. I can’t ask all of my site visitors to do a CTRL+R to be sure they see it correctly, so I’m looking for a way to counter this.
Is there anything I can do to, for example, refrain the custom.css from caching? I don’t want to turn off caching in general, of course. Any suggestions, please?
Thanks in advance!
March 9, 2015 at 9:12 pm #408456Hi DavyE!
It’s most likely a caching plugin your using. You can check in the plugin settings to see if you can stop the CSS from caching. Or just clear the plugin cache after your done doing your changes.
Best regards,
ElliottMarch 10, 2015 at 10:18 am #408699Thanks for your feedback Elliott!
I’ll try flushing the cache next time, but I assumed it would be purely local caching because some people see it and some don’t. If new visitors see it correctly, while returning visitors don’t, doesn’t that mean it’s the local caching? If it would be server side caching, I suppose new visitors would see the same thing, no?
Sorry if I get this all wrong, it’s a bit confusing.
March 10, 2015 at 8:19 pm #409053Hi!
Well in that case yes it sounds like the browser cache. I’ve never done this before but you could try reducing the amount of time your CSS is cached, http://gtmetrix.com/leverage-browser-caching.html.
If your constantly doing CSS changes then that may be a good idea. Most people keep their site under maintenance mode until it is completely finished and then release it.
Cheers!
Elliott- This reply was modified 9 years, 8 months ago by Elliott.
March 11, 2015 at 12:32 pm #409768Hello again Elliott,
Thanks for the suggestion. Unfortunately I cannot change the .htaccess file on my hosting provider. Also, I’d prefer to just disable caching for one specific file (custom.css) as that is the one that changes the most when modifying CSS for the Enfold theme. I rarely touch other files.
I found this, but not sure where I would add this to the theme and how to specify it should refer to custom.css instead of style.css (unless I just change “style.css” to “custom.css”):
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); echo '?' . filemtime( get_stylesheet_directory() . '/style.css'); ?>" type="text/css" media="screen, projection" />
This basically automatically adds a version number to the file so it is regarded as a new file and requests a fresh download.My site is never completely finished. New things get added, changed and optimised daily. I often overrule existing style (specified by Enfold), but if the visitors don’t see my version, they will see a broken result.
For example:
I added a new fullscreen slider to the homepage. I set the caption to “center without frame”. This already has existing styles specified by Enfold, but I need to change several aspects of it, such as the positioning (top instead of middle, etc.). If the visitors still have the previous custom.css version in their cache in which that style isn’t overruled yet, they will see the caption in the middle of my picture instead of at the intended top position, and so on.If tomorrow I change my fullscreen slider and want to change the font-family, this too will be done in custom.css, but only those who do a force refresh (= no one except me) will see the change.
Personally, I don’t even think the custom.css file should be cached in the first place, or not longer than a single session (like only lasting an hour). That is THE file we (Enfold users) will probably be modifying the most and the small file size would most likely not even impact load speed at all. If that’s the file we modify the most, I assume everyone would prefer these changes to be immediate.
Using the custom CSS text area in Enfold options (inside WP admin) is not a solution for me. Not all styles are accepted (for example changing font types), possibly because there are still other styles rendered below it. And I have about 10 languages, meaning I need to copy-paste every single change to every language. I also find it too risky to add anything there, because there is no turning back after saving changes (undo, backup different versions, …).
March 11, 2015 at 9:42 pm #410129Hey!
Around line 288 in the functions.php file you can see where we enqueue the custom.css stylesheet.
wp_register_style( 'avia-custom', $template_url."/css/custom.css", array(), '2', 'all' );
The “2” is the version.
Maybe something like this would work.
$last_modified = filemtime( $template_url . '/css/custom.css' ); wp_register_style( 'avia-custom', $template_url."/css/custom.css", array(), $last_modified, 'all' );
Regards,
ElliottMarch 12, 2015 at 3:13 pm #410490Thanks Elliott! I’ve added it to the site (so far so good, didn’t break the site yet) and will do some tests to see if it works.
March 14, 2015 at 3:57 am #411376March 16, 2015 at 4:04 pm #412247Ok Ismael, I’ll definitely let you know. So far no issues, but waiting for an opportunity to arise where I can clearly see if this works.
-
AuthorPosts
- The topic ‘Custom.css caching issue’ is closed to new replies.