AnswerBun.com

Edited css not updated in XAMPP

Joomla Asked by advait-varma on December 9, 2021

I am new to Joomla and just downloaded a template (from my company) and deployed it on XAMPP.

When I try to edit the CSS and refresh the page, the css does not get updated. I have tried clearing the cache and refreshing, but no such luck.

One Answer

Joomla's default Protostar template includes CSS files with

JHtml::_('stylesheet', 'template.css', array('version' => 'auto', 'relative' => true));

The ['version' => 'auto'] adds a media version MD5 hash as token to the file. The media version is regenerated by Joomla whenever anything is installed on the Joomla instance. See https://docs.joomla.org/J3.x:Adding_JavaScript_and_CSS_to_the_page#.24options_and_.24attributes_Parameters

The media version does NOT change when you make changes in your CSS. You could add your own timestamp to force a browser to re-load the CSS instead using it from cache.

In your template's index.php you could add something like:

use JoomlaCMSHTMLHTMLHelper;

HTMLHelper::_(
    'stylesheet',
    'your-css-file.css',
    [
        'version'  => filemtime(JPATH_THEMES
            . '/your-template/css/your-css-file.css'),
        'relative' => true
    ]
);

Answered by pe7er on December 9, 2021

Add your own answers!

Related Questions

Generating a module instance from PHP

0  Asked on September 5, 2021 by ffrewin

   

Embed custom JS app in Joomla MVC

0  Asked on September 5, 2021 by miasto

     

Error when updating Gantry from 4.1.20 to 4.1.32

1  Asked on September 5, 2021 by norberto-gomes

       

Change user permissions programmatically on the fly

1  Asked on September 5, 2021 by aheavyobject

   

Akeeba backup update broke the site

2  Asked on September 5, 2021 by hamlet-kraskian

   

Proper way for autoloading in Joomla 4

1  Asked on September 5, 2021 by webchun

     

Menu Specifically For Super Users

1  Asked on September 5, 2021

       

Joomla PHP does not match host PHP

2  Asked on February 18, 2021

     

Controller Joomla – Output Class construct for color css style

1  Asked on February 5, 2021 by andrea-suriani

       

Joomla custom component – router not find alias

1  Asked on January 21, 2021 by lecraver

     

Joomla 3 call model function inside controller

3  Asked on December 28, 2020 by wbdevlop

   

Product url problem after updating VirtueMart

1  Asked on December 23, 2020 by kiasaty

     

Display intro image inside mod_breadcrumbs

0  Asked on November 11, 2020 by geoplous

   

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP