TransWikia.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!

Ask a Question

Get help from others!

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