Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO: Cache logic improvement #111

Open
junkurihara opened this issue Oct 13, 2023 · 5 comments
Open

TODO: Cache logic improvement #111

junkurihara opened this issue Oct 13, 2023 · 5 comments

Comments

@junkurihara
Copy link
Owner

Considering to use unique and distinct UUID as filename even for the same URL at every cache time

@paulocoghi
Copy link

paulocoghi commented Oct 13, 2023

A common strategy used on Nginx is using $scheme$request_method$host$request_uri as the cache filename format.

Optionally, since some sites provide different versions for mobile and desktop, a more elaborate strategy is:

map $http_user_agent $mobile_request
{
	default    fullversion;

	"~*ipad"    fullversion;

	"~*android.*mobile"   mobileversion;
	"~*iphone"    mobileversion;
	"~*ipod.*mobile"   mobileversion;
	"~*BlackBerry*Mobile Safari"  mobileversion;
	"~*BB*Mobile Safari"   mobileversion;
	"~*Opera.*Mini/7"   mobileversion;
	"~*IEMobile/10.*Touch"   mobileversion;
	"~*IEMobile/11.*Touch"   mobileversion;
	"~*IEMobile/7.0"   mobileversion;
	"~*IEMobile/9.0"   mobileversion;
	"~*Firefox.*Mobile"   mobileversion;
	"~*webOS"    mobileversion;
}

fastcgi_cache_key "$scheme$request_method$host$request_uri$mobile_request";

But I do not recommend the later, since most of the time, the page code is the same (and it just uses css rules for responsive design).

@junkurihara
Copy link
Owner Author

There still exist rooms of improvement in caching logic. But it has been updated by #127 with more secure way of biding cached file and memory pointer.

@paulocoghi
Copy link

Issue solved by merging #127 🎉

@junkurihara
Copy link
Owner Author

Thanks Paulo!

But I would like to keep this issue open since I think there exist rooms for more improvement in cache logic :-)

@nisbet-hubbard
Copy link

Apache does something like this, by incorporating hostname, protocol, port, path and any CGI arguments to the URL as well as elements defined by the Vary header when creating the hash.

With hash as cache key, it’d also be nice to be able to purge individual URLs from command line like htcacheclean does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants