question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Suggestion] different headers for some files

See original GitHub issue

Hi thanks for a great plugin,

I want to know how to set different headers for different files, is this possible ?

This could work nicely if it could be extended like this:

var defaultHeaders = {};

.pipe(publisher.publish(function(filepath) {
        // even better if it supported globs
	if (filepath === './dist/index.html') {
		return {
			'Cache-Control': 'max-age=315360000, no-transform, public'
		}
	}

        return defaultHeaders;
}))

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

3reactions
sp90commented, Dec 15, 2016

I made this work by doing 2, with different cache file names, and then setting the index file that i want to add a different header. And in the second task only do file upload

gulp.task('copyIndexToS3', function() {
	// If the aws file are unavailable do nothing
	if (!awsKeys) {
		// To setup permissions, and policies check the article linked in the top
		console.log('Setup your aws keys, and bucket correctly guidelines are found in the link in gulp/cdn-s3.js file');
		return gulp.src('./dist/**');
	}

	var keysObj = live === true ? awsKeys.prod : awsKeys.dev;
	var publisher = awspublish.create(keysObj, {
		cacheFileName: '.awspublish-' + env + '.example.com-index'
	});
	return gulp.src([
			'dist/index.html'
		])
		.pipe(awspublish.gzip())
		.pipe(publisher.publish({
			'Cache-Control': 'no-cache, no-store, must-revalidate',
			'Expires': 0
		}, {
			createOnly: true
		}))
		.pipe(publisher.cache())
		.pipe(awspublish.reporter());
});

gulp.task('copyToS3', function() {
	// If the aws file are unavailable do nothing
	if (!awsKeys) {
		// To setup permissions, and policies check the article linked in the top
		console.log('Setup your aws keys, and bucket correctly guidelines are found in the link in gulp/cdn-s3.js file');
		return gulp.src('./dist/**');
	}

	var keysObj = live === true ? awsKeys.prod : awsKeys.dev;
	var publisher = awspublish.create(keysObj, {
		cacheFileName: '.awspublish-' + env + '.example.com'
	});

	return gulp.src([
			'dist/**',
			'!dist/index.html',
			'!dist/**/*.test*',
			'!dist/rev-manifest.json',
		])
		.pipe(awspublish.gzip())
		.pipe(publisher.publish({
			'Cache-Control': 'max-age=315360000, no-transform, public'
		}))
		.pipe(publisher.cache())
		.pipe(publisher.sync())
		.pipe(awspublish.reporter());
});
1reaction
skeggsecommented, Feb 20, 2019

Related to #23?

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - How to include different headers from different folders?
I have a C++ project and I love mycode organized, however when I put everything in separate directories (headers and source files kept ......
Read more >
Combine multiple files with one different header
I have 60+ files that I need to regularly combine into one and do a bit of formatting on. I have tried to...
Read more >
Eight advanced tips for Word headers and footers
1. Display page numbers in shapes ... Most documents over a few pages display a page number in the header of footer. If...
Read more >
How can I get a different header/footer on the second page?
Then type in the material for the header / footer to go on the first page. Uncheck the Different First Page checkbox and...
Read more >
Feature Suggestion: personal headers - Codeforces
say... 64kb, such that every time they submit a file, the Codeforces grading system will compile/run said file with -I/my_include_directory/ (or other language ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found