Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
edd34ebb
Commit
edd34ebb
authored
13 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
use etagify for content-based hashes in ETag headers - issue #1331
parent
1971ecc8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/local.json
+2
-2
2 additions, 2 deletions
config/local.json
lib/browserid/views.js
+16
-20
16 additions, 20 deletions
lib/browserid/views.js
package.json
+1
-0
1 addition, 0 deletions
package.json
with
19 additions
and
22 deletions
config/local.json
+
2
−
2
View file @
edd34ebb
...
...
@@ -9,6 +9,6 @@
"driver"
:
"json"
},
"express_log_format"
:
"dev_bid"
,
"email_to_console"
:
true
"email_to_console"
:
true
,
"env"
:
"local"
}
This diff is collapsed.
Click to expand it.
lib/browserid/views.js
+
16
−
20
View file @
edd34ebb
...
...
@@ -11,14 +11,14 @@ connect = require('connect'),
config
=
require
(
'
../configuration.js
'
),
und
=
require
(
'
underscore
'
),
util
=
require
(
'
util
'
),
httputils
=
require
(
'
../httputils.js
'
);
httputils
=
require
(
'
../httputils.js
'
),
etagify
=
require
(
'
etagify
'
);
// all templated content, redirects, and renames are handled here.
// anything that is not an api, and not static
const
path
=
require
(
'
path
'
);
const
VIEW_PATH
=
path
.
join
(
__dirname
,
"
..
"
,
"
..
"
,
"
resources
"
,
"
views
"
);
// none of our views include dynamic data. all of them should be served
...
...
@@ -26,27 +26,23 @@ const VIEW_PATH = path.join(__dirname, "..", "..", "resources", "views");
// cache headers maximally leveraging the same logic that connect uses
// issue #910
function
renderCachableView
(
req
,
res
,
template
,
options
)
{
fs
.
stat
(
path
.
join
(
VIEW_PATH
,
template
),
function
(
err
,
stat
)
{
res
.
setHeader
(
'
Date
'
,
new
Date
().
toUTCString
());
res
.
setHeader
(
'
Vary
'
,
'
Accept-Encoding,Accept-Language
'
);
if
(
config
.
get
(
'
env
'
)
!==
'
local
'
)
{
// allow caching, but require revalidation via ETag
res
.
setHeader
(
'
Cache-Control
'
,
'
public, max-age=0
'
);
res
.
setHeader
(
'
ETag
'
,
util
.
format
(
'
"%s-%s-%s"
'
,
stat
.
size
,
Number
(
stat
.
mtime
),
req
.
lang
));
}
else
{
res
.
setHeader
(
'
Cache-Control
'
,
'
no-store
'
);
}
res
.
setHeader
(
'
Content-Type
'
,
'
text/html; charset=utf8
'
);
if
(
connect
.
utils
.
conditionalGET
(
req
))
{
if
(
!
connect
.
utils
.
modified
(
req
,
res
))
{
return
connect
.
utils
.
notModified
(
res
);
}
}
res
.
render
(
template
,
options
);
});
if
(
config
.
get
(
'
env
'
)
!==
'
local
'
)
{
// allow caching, but require revalidation via ETag
res
.
etagify
();
res
.
setHeader
(
'
Cache-Control
'
,
'
public, max-age=0
'
);
}
else
{
// disable all caching for local dev
res
.
setHeader
(
'
Cache-Control
'
,
'
no-store
'
);
}
res
.
setHeader
(
'
Date
'
,
new
Date
().
toUTCString
());
res
.
setHeader
(
'
Vary
'
,
'
Accept-Encoding,Accept-Language
'
);
res
.
setHeader
(
'
Content-Type
'
,
'
text/html; charset=utf8
'
);
res
.
render
(
template
,
options
);
}
exports
.
setup
=
function
(
app
)
{
app
.
use
(
etagify
());
app
.
set
(
"
views
"
,
VIEW_PATH
);
app
.
set
(
'
view options
'
,
{
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
0
View file @
edd34ebb
...
...
@@ -14,6 +14,7 @@
"
connect-cookie-session
"
:
"
0.0.2
"
,
"
connect-logger-statsd
"
:
"
0.0.1
"
,
"
ejs
"
:
"
0.4.3
"
,
"
etagify
"
:
"
0.0.1
"
,
"
express
"
:
"
2.5.0
"
,
"
iconv
"
:
"
1.1.3
"
,
"
jwcrypto
"
:
"
0.1.1
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment