1

We are adding versions to css and js files to do cache busting. I have used gulp-rev-manifest and gulp-rev-collector to achieve this. But every time we do a build all the updated files with the new version number and have to be pushed to production which is not ideal. Is there any other way to do this.

Thanks

lalitha
  • 11
  • 2

1 Answers1

0

You can modify the links to the linked files to include version numbers rather than renaming files. Serve this:

<script type="text/javascript" src="script.js?ver=1"></script>

Then the next time you gulp have the link say:

<script type="text/javascript" src="script.js?ver=2"></script>

By appending a new parameter string you override the browser cache. This can be done on every gulp, and the browser will grab the file from the server. You won't need to upload all of the files for every new deployment.

gulp: Automatically add version number to request for preventing browser cache

JasonB
  • 6,243
  • 2
  • 17
  • 27