The Browser Is Not Updating My CSS File When I'm Using XAMPP - TagMerge
4The Browser Is Not Updating My CSS File When I'm Using XAMPPThe Browser Is Not Updating My CSS File When I'm Using XAMPP

The Browser Is Not Updating My CSS File When I'm Using XAMPP

Asked 1 years ago
1
4 answers

You can add a version number to the css link like the folowing :

<link rel="stylesheet" type="text/css" href="style.css?ver=1.1/>

Source: link

0

Add a random version number at the end of the css file you are attaching. If you are using 'wp_enqueue_style' or wp_register_style functions, pass a random (version) number rand(111,9999) to 4th parameter. If you are attaching css as an html tag, you should add "?ver=<?php echo rand(111,999)?>" at the end of the file name. Examples are here
wp_register_style( 'custom-style', get_template_directory_uri() . '/css/custom-style.css', array(), rand(111,9999), 'all' );
or
<link rel="stylesheet" type="text/css" href="http://website.com/css/custom-style.css?ver=<?php echo rand(111,999)?>">
Modify this according to your need, works like a charm, generates random version number each time you reload the page, perfect for development :
wp_enqueue_style('mypluginstyle',  plugins_url('/assets/mystyle.css', __FILE__), array(), rand(111,9999) );
Please change the version in top of style.css file (location ..wp-content\themes\theme_name\style.css) to a newer.
/*
Theme Name: SF TEST
Version: 1.0.1
*/
also, change the version in fuction.php file for that CSS file
wp_enqueue_style('style', get_template_directory_uri() . "/assets/css/style.css", array(), '1.0', 'all');

Source: link

0

You may try queries to force the browser to load fresh CSS when it loads. To do this
<link rel="stylesheet" type="text/css" href="css-file-name.css?v=1.1">
If you are comfortable with php you may try below code to force the browser to load most updated CSS to load. To do this
<link rel="stylesheet" type="text/css" href="http://example.com/style.css?d=<?php echo time(); ?>" />

Source: link

0

I have recently updated a CSS file onto the web with a slight change in, to make a certain text blue instead of red:
p.melding{
    font-weight: bold;
    color: blue; /*red earlier*/
}
The link to the stylesheet:
<head>
    <title>...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" href="stil.css" type="text/css" media="screen" />
  </head>
and the php code concerning the class in question:
<?php
  if (isset($melding)) {
    echo "            <p class=\"melding\">$melding

\n"; } ?>

Source: link

Recent Questions on css

    Programming Languages