How to add CacheHash to every link generated in the website.

On the file EXT:myext/Classes/Xclass/ContentObjectRenderer.php



<?php
namespace TYPO3\Myext\Xclass;

class ContentObjectRenderer extends \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer {

    /**
     * Sets useCacheHash = 1 for all links
     *
     * @param string $linktxt The string (text) to link
     * @param array $conf TypoScript configuration
     * @return string A link-wrapped string.
     */
     
    function typoLink($linktxt, $conf) {
        $conf['useCacheHash'] = 1;
        
        $typolink =  parent::typoLink($linktxt, $conf);

        return $typolink;
    }
}



On the file EXT:myext/ext_localconf.php


// Define Xclass. Set the cHashes for the content links.
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'] = array(
    'className' => 'TYPO3\\Myext\\Xclass\\ContentObjectRenderer'
);