Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443915
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
Issue forks
drupal-3443915
Commits
59cb3c45
Commit
59cb3c45
authored
19 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#13224
by Richard Archer and Gerhard: improved gzip caching.
parent
fd96728f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/bootstrap.inc
+24
-5
24 additions, 5 deletions
includes/bootstrap.inc
with
24 additions
and
5 deletions
includes/bootstrap.inc
+
24
−
5
View file @
59cb3c45
...
...
@@ -380,6 +380,16 @@ function cache_clear_all($cid = NULL, $wildcard = false) {
/**
* Store the current page in the cache.
*
* We try to store a gzipped version of the cache. This requires the
* PHP zlib extension (http://php.net/manual/en/ref.zlib.php).
* Presence of the extension is checked by testing for the function
* gzencode. There are two compression algorithms: gzip and deflate.
* The majority of all modern browsers support gzip or both of them.
* We thus only deal with the gzip variant and unzip the cache in case
* the browser does not accept gzip encoding.
*
* @see drupal_page_header
*/
function
page_set_cache
()
{
global
$user
,
$base_url
;
...
...
@@ -387,16 +397,23 @@ function page_set_cache() {
if
(
!
$user
->
uid
&&
$_SERVER
[
'REQUEST_METHOD'
]
==
'GET'
)
{
// This will fail in some cases, see page_get_cache() for the explanation.
if
(
$data
=
ob_get_contents
())
{
$cache
=
TRUE
;
if
(
function_exists
(
'gzencode'
))
{
if
(
version_compare
(
phpversion
(),
'4.2'
,
'>='
))
{
$data
=
gzencode
(
$data
,
9
,
FORCE_GZIP
);
// We do not store the data in case the zlib mode is deflate.
// This should be rarely happening.
if
(
zlib_get_coding_type
()
==
'deflate'
)
{
$cache
=
FALSE
;
}
else
{
$data
=
gzencode
(
$data
,
FORCE_GZIP
);
else
if
(
zlib_get_coding_type
()
==
FALSE
)
{
$data
=
gzencode
(
$data
,
9
,
FORCE_GZIP
);
}
// The remaining case is 'gzip' which means the data is
// already compressed and nothing left to do but to store it.
}
ob_end_flush
();
cache_set
(
$base_url
.
request_uri
(),
$data
,
CACHE_TEMPORARY
,
drupal_get_headers
());
if
(
$cache
&&
$data
)
{
cache_set
(
$base_url
.
request_uri
(),
$data
,
CACHE_TEMPORARY
,
drupal_get_headers
());
}
}
}
}
...
...
@@ -569,6 +586,8 @@ function drupal_set_title($title = NULL) {
/**
* Set HTTP headers in preparation for a page response.
*
* @see page_set_cache
*/
function
drupal_page_header
()
{
if
(
variable_get
(
'cache'
,
0
))
{
...
...
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