gulp-awspublish always updates files, even when there are no changes

I have just started using gulp-awspublish to help manage a nuxt universal app I created. I thought it would be worth sharing my experience here because I did not find any articles about similar problems. My application is currently very small so this is really only an annoyance. However, it could be problematic for larger apps because many files will be unnecessarily uploaded potentially resulting in higher fees.

gulp-awspublish uses aws etags to detect changes. An etag is basically an md5sum it should accurately detect changes. When I looked into what gulp-awspublish was doing I noticed the etag was changing. This issue turned out to be the nuxt google-adsense-module. To support updating ads on Single Page Applications (SPAs) the nuxt google-adsense-module sets the data-ad-region to a randomly generated value every time the component is loaded. Normally this is not a problem but because this means the page that gets generated always has a different data-ad-region attribute when it gets regenerated. This makes the page different can causes gulp-awspublish to update the page even though nothing should have changed.

I fixed this by removing the data-ad-region attribute from the component. I did not need this because my app in not an SPA. It now works as expected an if I run gulp twice the second time no files are pushed to S3.

Comments

Popular Posts