Versioned assets

Submitted by decipher - 9 months 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') }}">
comments powered by Disqus