Bozohttpd

Check-in [dda2552f49]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Set cache-control only for images

A bit of an intermediate commit, just investigating what works. I think really
need to be able to pass in a string and a cache-control header and it'll use
strstr to determine which header to set. I.e so you can pass in:

"image" "max-age=604800"
"css" "max-age=86400"

The bit I'm then missing is how to set a catch all or "owtelse" cache-control?
Maybe look for one argument?

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dda2552f490e3374281ecbd09738fd896ea950b3
User & Date: atomicules 2017-11-25 22:13:18
Context
2017-12-02
22:37
Use existing content_map to provide cache control header per file type

Ideally I'd prefer to do it with a regex or partial match on the content type, but everything is already setup for us to piggyback on this instead. I.e. I'd like to do multiple arguments like this:

-h "image" "private, max-age=604800" -h "css" "private, max-age=86400"

or a single argument where we split the string on a comma:

-h "image,css" "private, max-age=604800"

but instead I am happy enough to be able to do:

-h .jpg "private, max-age=604800" -h .png "private, max-age=86400"

It's good enough for what I want to stop here.

- Adds a new cache-bozo.c file
- Adds a new field in the existing map used for the cache control header
- Extends all existing functions as required to reference this new field. Leaf check-in: 6d39f799f6 user: atomicules tags: trunk

2017-11-25
22:13
Set cache-control only for images

A bit of an intermediate commit, just investigating what works. I think really
need to be able to pass in a string and a cache-control header and it'll use
strstr to determine which header to set. I.e so you can pass in:

"image" "max-age=604800"
"css" "max-age=86400"

The bit I'm then missing is how to set a catch all or "owtelse" cache-control?
Maybe look for one argument? check-in: dda2552f49 user: atomicules tags: trunk

19:08
Initial work on setting Cache-Control headers

The bit that foxed me was understanding getopts and that the "h" needed a ":"
after it because the option accepts and argument. It'll happily build and run
without this, but segfault when you try to use a "-h" argument.

This definitely and utterly sets a header. It doesn't seem that it's recognised
properly for whatever reason though, e.g here:

- https://developers.google.com/speed/pagespeed/insights/

and here:

- http://highloadtools.com/cachecontrol

But what can you do?

At the moment this just sets a header everywhere for everything being served.
What would be better would be just setting this on certain file types. check-in: a29fb4fb10 user: atomicules tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bozohttpd.c.

1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
		struct	tm *tm;

		tm = gmtime(&sbp->st_mtime);
		strftime(filedate, sizeof filedate,
		    "%a, %d %b %Y %H:%M:%S GMT", tm);
		bozo_printf(httpd, "Last-Modified: %s\r\n", filedate);
	}
	if (httpd->cache_control_headers)
		bozo_printf(httpd, "Cache-Control: %s\r\n", httpd->cache_control_headers);
	if (type && *type)
		bozo_printf(httpd, "Content-Type: %s\r\n", type);
	if (encoding && *encoding)
		bozo_printf(httpd, "Content-Encoding: %s\r\n", encoding);
	if (sbp) {
		if (request->hr_have_range) {







|







1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
		struct	tm *tm;

		tm = gmtime(&sbp->st_mtime);
		strftime(filedate, sizeof filedate,
		    "%a, %d %b %Y %H:%M:%S GMT", tm);
		bozo_printf(httpd, "Last-Modified: %s\r\n", filedate);
	}
	if (httpd->cache_control_headers && (strstr(type, "image") != NULL))
		bozo_printf(httpd, "Cache-Control: %s\r\n", httpd->cache_control_headers);
	if (type && *type)
		bozo_printf(httpd, "Content-Type: %s\r\n", type);
	if (encoding && *encoding)
		bozo_printf(httpd, "Content-Encoding: %s\r\n", encoding);
	if (sbp) {
		if (request->hr_have_range) {