You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,6 +150,13 @@ return [
150
150
151
151
If you use a custom root and/or prefix, please modify the following server configuration examples accordingly.
152
152
153
+
If your custom root is outside of the server's document root, users have been successful with these solutions:
154
+
155
+
- Create a symbolic link (symlink) from your custom root to a path inside the document root. Then use the path inside the document root in the server configuration. For this to work, the server needs to be set up to follow symlinks.
156
+
- In an Apache setup: Replace the `%{DOCUMENT_ROOT}` variable with the absolute path to your custom root on the server. E.g. `RewriteCond /var/www/yourPath/%{REQUEST_URI}/...`
157
+
158
+
In any case, please ensure that your web server has read access to the cache files in your custom root, otherwise it will not be able to handle requests with the statically cached files.
159
+
153
160
### Web server integration
154
161
155
162
This plugin will automatically generate and store the cache files, however you need to configure your web server to pick the files up and prefer them over a dynamic result from PHP.
@@ -228,10 +235,17 @@ To load the static cache files from PHP, please place the following code snippet
228
235
return;
229
236
}
230
237
238
+
// try to determine the content type from the static file
239
+
if ($mime = @mime_content_type($path)) {
240
+
header("Content-Type: $mime");
241
+
}
242
+
231
243
die(file_get_contents($path));
232
244
})();
233
245
```
234
246
247
+
If you want to use the PHP loader, we recommend to use it together with header support (see below). Storing the headers increases performance by a bit and also gives you more accurate responses.
248
+
235
249
### Header support
236
250
237
251
Staticache stores only the response bodies by default. The HTTP status code as well as headers set by your pages are not preserved in this mode. This ensures compatibility with all web servers.
@@ -268,7 +282,7 @@ Afterwards add the following block to your `.htaccess` file to make Apache use `
268
282
269
283
**PHP loader:**
270
284
271
-
Replace the last line of the loader function with this code:
285
+
Replace the last six lines of the loader function with this code:
272
286
273
287
```php
274
288
// split the file into headers (before two line breaks) and body
0 commit comments