Advertisement
rodro1

Auto clear cache php

Jul 23rd, 2020 (edited)
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. First htaccess
  2.  
  3. RewriteEngine On
  4. # When any change applied reload css and js
  5. RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]
  6.  
  7. //helper function
  8. function auto_version($file) // its for when change applied clear cashe and reload
  9. {
  10. if(strpos($file, '/') !== 0 || !file_exists($_SERVER['DOCUMENT_ROOT'] . $file))
  11. return $file;
  12.  
  13. $mtime = filemtime($_SERVER['DOCUMENT_ROOT'] . $file);
  14. return preg_replace('{\\.([^./]+)$}', ".$mtime.\$1", $file);
  15. }
  16.  
  17. //html
  18. <link rel="stylesheet" href="{{ auto_version('frontend/style-black.css') }}">
  19.  
  20.  
  21. Option 2
  22. ===
  23. <!--responsive css-->
  24. <link rel="stylesheet" type="text/css" href="{{ asset('assets/css/custom.css') . '?v=' . filemtime(base_path() . '/assets/css/custom.css') }}">
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement