E
E
error4012019-08-09 17:05:22
caching
error401, 2019-08-09 17:05:22

How to force refresh site user's cache (wordpress)?

Hello. Faced such a problem. I make changes to the styles on any pages of the site, I update the page. The changes do not take effect until I refresh the page via ctrl+f5 or clear the site cache with the plugin (WP Super cache).
Previously, the plugin saved, but now, no matter how I try to clear the cache, nothing helps except ctrl + f5.
The bottom line is, most users do not understand that they need to clear the cache and refresh the page via ctrl + f5 and when they enter the site, they see an ugly page with no styles or with old styles.
It is necessary to make it so that when entering the updated pages of the site, without ctrl + f5, the user immediately sees the updated version of the page.
Here is what I tried:
1) On the hosting side, through the support service, disabled css file caching - it didn’t help (apparently the old cache remained with users)
2) Deleted the cache a thousand times using the WP Super Catch plugin - it didn’t help
3) In the WP php file in which the main file is connected styles, added "?ver=123" to this file - did not help.
Here's what it looked like:
It was:

wp_enqueue_style('main', get_template_directory_uri() . '/css/emmet-style.min.css', array(
        'bootstrap',
        'font-awesome'
    ), mp_emmet_get_theme_version(), 'all');

It became:
wp_enqueue_style('main', get_template_directory_uri() . '/css/emmet-style.min.css?ver=777', array(
        'bootstrap',
        'font-awesome'
    ), mp_emmet_get_theme_version(), 'all');

Help out, please. How to update this fucking cache forcibly on the user's side, so that when the user enters the page, fresh, updated styles are loaded? It would seem that such a trifle, but it does a lot of harm to the site at the moment and I can’t do anything about it.
There is a suspicion that the 3rd method does not help to solve the problem, because of this line: As far as I understand, WP automatically somehow sets the css version to the style file and that I manually set the version to the emmet-style.min.css file - had no effect
mp_emmet_get_theme_version(), 'all');

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Druzhaev, 2019-08-09
@error401

And the console (f12) shows you on the Network tab what version of css? emmet-style.min.css?ver=777 ?
Or not?

E
error401, 2019-08-09
@error401

Solved the problem.
Here in this code:

wp_enqueue_style('main', get_template_directory_uri() . '/css/emmet-style.min.css', array(
        'bootstrap',
        'font-awesome'
    ), mp_emmet_get_theme_version(), 'all');

I replaced mp_emmet_get_theme_version()
with
This way, the version of the CSS file has been replaced and the styles on the site are now updated without clearing the cache

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question