{"id":13448071,"url":"https://github.com/jonathantneal/http-client-hints","last_synced_at":"2026-03-13T23:31:13.816Z","repository":{"id":10559584,"uuid":"12761406","full_name":"jonathantneal/http-client-hints","owner":"jonathantneal","description":"Hurray for server-side content negotiation","archived":false,"fork":false,"pushed_at":"2013-09-25T19:16:28.000Z","size":156,"stargazers_count":126,"open_issues_count":1,"forks_count":7,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-10-28T08:53:39.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathantneal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-11T16:31:35.000Z","updated_at":"2024-06-25T15:37:03.000Z","dependencies_parsed_at":"2022-09-10T04:23:29.736Z","dependency_job_id":null,"html_url":"https://github.com/jonathantneal/http-client-hints","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonathantneal/http-client-hints","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathantneal%2Fhttp-client-hints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathantneal%2Fhttp-client-hints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathantneal%2Fhttp-client-hints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathantneal%2Fhttp-client-hints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathantneal","download_url":"https://codeload.github.com/jonathantneal/http-client-hints/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathantneal%2Fhttp-client-hints/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30479323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T20:45:58.186Z","status":"ssl_error","status_checked_at":"2026-03-13T20:45:20.133Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:34.744Z","updated_at":"2026-03-13T23:31:13.800Z","avatar_url":"https://github.com/jonathantneal.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# HTTP Client Hints\n\nThe Client Hints (CH) header communicates device capabilities to the server, allowing the server to return the best possible experience back to the device.\n\nThis project aims to polyfill \u003cabbr title=\"Client Hints\"\u003eCH\u003c/abbr\u003e to the best abilities of the device and server.\n\n[HTTP Client Hints Draft](//github.com/igrigorik/http-client-hints)\n\n## How it works:\n\nOne line of JavaScript can make a variety of hints available to the server. For instance, if the following script is included at the top of the document, all future requests (even those made from that same document) can leverage these hints. The draft calls for 3 hints; device pixel ratio, device width, and device height.\n\n```javascript\ndocument.cookie = 'CH=dh=' + screen.height +\n\t',dpr=' + (window.devicePixelRatio || 1) +\n\t',dw=' + screen.width +\n\t',t' + ('ontouchstart' in window || 'msMaxTouchPoints' in navigator) +\n\t';expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/';\n```\n\nOr as [separated hints](https://github.com/igrigorik/http-client-hints/issues/14).\n\n```javascript\n(function (p, e, k) {\n\tfor (k in p) document.cookie = 'CH-' + k + '=' + p[k] + e;\n})({\n\tDH: screen.height,\n\tDW: screen.width,\n\tDPR: window.devicePixelRatio || 1,\n\tT: 'ontouchstart' in window || 'msMaxTouchPoints' in navigator\n}, ';expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/');\n```\n\nSince these 3 \u003cabbr title=\"Client Hints\"\u003eCH\u003c/abbr\u003e are unlikely to change in a given session, the above snippet could be wrapped in a server-side conditional to load just once.\n\n```php\n\u003c?php if (!isset($_SERVER['HTTP_CH'])) : ?\u003e\n\t\u003cscript\u003edocument.cookie = ...\u003c/script\u003e\n\u003c?php endIf; ?\u003e\n```\n\nThe native implementation of \u003cabbr title=\"Client Hints\"\u003eCH\u003c/abbr\u003e works by sending hints through a request header, which the server could cache. This polyfill emulates the projected end-result \u0026mdash; a server with a cache of hints.\n\n## What is included:\n\n### create.htaccess\n\nAn Apache configuration snippet for converting a \u003cabbr title=\"Client Hints\"\u003eCH\u003c/abbr\u003e cookie into a server environment variable.\n\n### create.js\n\nA JavaScript snippet for creating a \u003cabbr title=\"Client Hints\"\u003eCH\u003c/abbr\u003e cookie.\n\n### create.php\n\nA PHP snippet for conditionally creating a \u003cabbr title=\"Client Hints\"\u003eCH\u003c/abbr\u003e cookie when the server environment variable is not yet found.\n\n## What the future holds:\n\nAn [issue on GitHub](//github.com/igrigorik/http-client-hints/issues/3) suggests including more dynamic data in \u003cabbr title=\"Client Hints\"\u003eCH\u003c/abbr\u003e, such as device orientation, viewport size, and zoom level as well.\n\nAdmittedly, these values [*\u003cq\u003echange frequently and are difficult to cache\u003c/q\u003e*](//github.com/igrigorik/http-client-hints/issues/3#issuecomment-14573532), whereas the currently drafted hints are unlikely to change in the life of the device.\n\nSince \u003cabbr title=\"Client Hints\"\u003eCH\u003c/abbr\u003e adoption is in its early stages, [Ilya Grigorik](//twitter.com/igrigorik), author of the [HTTP Client Hints Draft](//github.com/igrigorik/http-client-hints), argues that the [*\u003cq\u003eCH header must be kept as small and as static as possible to prove its viability\u003c/q\u003e*](//github.com/igrigorik/http-client-hints/issues/3#issuecomment-14427978).\n\n## Native implementation status:\n\n* [Latest Client Hints draft on IETF tracker](//tools.ietf.org/html/draft-grigorik-http-client-hints)\n* [Blink intent to implement thread](//groups.google.com/a/chromium.org/d/msg/blink-dev/c38s7y6dH-Q/bNFczRZj5MsJ) ([patch under review](//codereview.chromium.org/23654014))\n\n---\n\nAll of these contributions to \u003cabbr title=\"Client Hints\"\u003eCH\u003c/abbr\u003e are dedicated to the [public domain with no copyright](//creativecommons.org/publicdomain/zero/1.0/).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathantneal%2Fhttp-client-hints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathantneal%2Fhttp-client-hints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathantneal%2Fhttp-client-hints/lists"}