connect-static-expiry icon indicating copy to clipboard operation
connect-static-expiry copied to clipboard

EJS support

Open cookie-ag opened this issue 8 years ago • 5 comments

I did the config as follows

app.use(expiry(app, {
    dir: path.join(__dirname, 'public'),
    duration: 31556900
}));
app.use(express.static(path.join(__dirname, 'public'), {
    maxage: config.oneDay
}, {
    etag: config.etagAllow
}, {
    dotfiles: config.Allowdotfiles
}));

and defined the route as <link rel="stylesheet" type="text/css" href="<%= furl(../vendor/main_Lib.min.css) %>">

but the resource fails to load?

cookie-ag avatar Aug 27 '16 14:08 cookie-ag

Without more context, it's hard to know what's going on here. However, the most likely culprit is the ../vendor. The furl function expects the public, root-relative url for the file, just without the fingerprint, not the path to the file on disk.

ethanresnick avatar Nov 26 '16 09:11 ethanresnick

this is settable in the options but perhaps it's best to allow for an ENV var?

paulwalker avatar Nov 26 '16 09:11 paulwalker

Not sure I understand... what is settable in options?

ethanresnick avatar Nov 26 '16 09:11 ethanresnick

the public directory. but if there is code that does not recognize this setting, that is a bug.

paulwalker avatar Nov 26 '16 09:11 paulwalker

You're talking about the dir setting, right? If so, yeah, that sets where to find the static files on disk, and it is being used to locate the files for fingerprinting.

My point was that the furl() function's argument isn't the path to the file on disk, but is rather the url for the file, just without the fingerprint. (In the issue report, it looked like @serganus was trying to pass the path to furl). Are you saying that furl should accept a path too, or we should make that configurable? If so, I'm not opposed (and maybe it's more intuitive?), though I don't really see why it'd be necessary either.

ethanresnick avatar Nov 26 '16 10:11 ethanresnick