xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit 7998f5b0ba9cbd06deb5a5e5270629f9213cf2b7

Use HTTP/1.1 caching only with HTTP/1.1 protocol.
Author: Catalin(ux) M. BOIE
Author date (UTC): 2015-06-18 21:46
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2015-06-18 21:46
Parent(s): 65d54e7a4a50527a22a4a325a2fb423b60acc77d
Signing key:
Tree: 3ea0bfeb7c7e4ce0f51b5748a16a9256a59418a2
File Lines added Lines deleted
root/index.php 18 13
File root/index.php changed (mode: 100644) (index 4a18a23..e5dc14c)
... ... if ($rg['login_ui']['uid'] > 0) {
155 155
156 156
157 157 $rg['HTML:rg_body'] = $body; $rg['HTML:rg_body'] = $body;
158 // DEBUG: aici deja e busit content-ul! Merg inapoi pe fir.
159 158 $_c = rg_template("index.html", $rg, TRUE /* xss */); $_c = rg_template("index.html", $rg, TRUE /* xss */);
160 159
161 160 header('Cache-Control: private, no-cache'); header('Cache-Control: private, no-cache');
162 161
163 162 // Caching // Caching
164 $we_have = sha1($_c);
165 if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
166 $client_have = $_SERVER['HTTP_IF_NONE_MATCH'];
167 else
168 $client_have = '';
169
170 if (strcmp($client_have, $we_have) == 0) {
171 rg_log('Client has the right version');
172 header('HTTP/1.1 304 Not modified');
173 header('ETag: ' . $we_have);
163 $proto = rg_var_str('SERVER_PROTOCOL');
164 rg_log('DEBUG: proto=' . $proto);
165 if (strcmp($proto, 'HTTP/1.1') == 0) {
166 $we_have = sha1($_c);
167 if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
168 $client_have = $_SERVER['HTTP_IF_NONE_MATCH'];
169 else
170 $client_have = '';
171
172 if (strcmp($client_have, $we_have) == 0) {
173 rg_log('CACHE: Client has the right version');
174 header('HTTP/1.1 304 Not modified');
175 header('ETag: ' . $we_have);
176 } else {
177 rg_log('CACHE: Client has NOT the right version [' . $client_have . ']');
178 header('ETag: ' . $we_have);
179 echo $_c;
180 }
174 181 } else { } else {
175 rg_log('Client has NOT the right version [' . $client_have . ']');
176 header('ETag: ' . $we_have);
177 182 echo $_c; echo $_c;
178 183 } }
179 184
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master