Skip to content

Instantly share code, notes, and snippets.

@stidges
Last active August 21, 2018 02:20
Show Gist options
  • Select an option

  • Save stidges/3d0c0317bf0d36073dd045bbcc742852 to your computer and use it in GitHub Desktop.

Select an option

Save stidges/3d0c0317bf0d36073dd045bbcc742852 to your computer and use it in GitHub Desktop.

Revisions

  1. stidges revised this gist Oct 18, 2016. No changes.
  2. stidges created this gist Oct 18, 2016.
    20 changes: 20 additions & 0 deletions CacheBustingLaravelValetDriver.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?php

    class CacheBustingLaravelValetDriver extends LaravelValetDriver
    {
    public function isStaticFile($sitePath, $siteName, $uri)
    {
    $result = parent::isStaticFile($sitePath, $siteName, $uri);

    if ($result !== false) {
    return $result;
    }

    if (preg_match('/(.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif)$/i', $uri, $matches)) {
    // Rewrite cache busted URIs to their original filename (e.g. jquery.1476809927.js to jquery.js)
    return $sitePath.'/public'.$matches[1].'.'.$matches[2];
    }

    return false;
    }
    }