Search code examples
cssbackendtypo3-10.x

How to prevent an asset css file from caching in a custom BE module?


I've found this line of code to embed custom css in my custom BE module extension.

<f:asset.css identifier="myextcss" href="EXT:myExt/Resources/Public/Css/myext.css" />

This works fine. But the browser caches this file - how do I prevent it from this? I know, that pages can be set non-cache in FE. But in BE I want only this file prevented from caching, not the whole module.


Solution

  • after some trying I found a workaround.

    I add these lines to my controller

    $mytoken = substr (str_shuffle($_GET['token']),0,8);
    $this->view->assign('mytoken', $mytoken);
    

    And this to my fluid:

    <f:asset.css identifier="myextcss" href="EXT:myExt/Resources/Public/Css/myext.css?{mytoken}" />
    

    So the browser find always a "new" file request and reload it.