Versioned assets

Submitted by decipher - 6 years ago

This helper will helps you to serve the assets which is last updated by the server. The Main aim of this helper to eliminate the cache of the assets we updated in server.

    /**
     * Generate a URL to an application asset with a versioned timestamp parameter.
     * @param $path
     * @param null $secure
     * @return string
     */
    static function versioned_asset($path, $secure = null)
    {
        $timestamp = @filemtime(public_path($path)) ?: 0;
        return asset($path, $secure) . '?' . $timestamp;
    }
    
    //in your master file
    <link rel="stylesheet" href="{{ AppHelpers::versioned_asset('styles/style.css') }}">