What is the X-REQUEST-ID http header?

When you’re operating a webservice that is accessed by clients, it might be difficult to correlate requests (that a client can see) with server logs (that the server can see). The idea of the X-Request-ID is that a client can create some random ID and pass it to the server. The server then include that … Read more

User recognition without cookies or local storage

Introduction If I understand you correctly, you need to identify a user for whom you don’t have a Unique Identifier, so you want to figure out who they are by matching Random Data. You can’t store the user’s identity reliably because: Cookies Can be deleted IP address Can change Browser Can Change Browser Cache may … Read more

PHP file_get_contents() and setting request headers

Actually, upon further reading on the file_get_contents() function: // Create a stream $opts = [ “http” => [ “method” => “GET”, “header” => “Accept-language: en\r\n” . “Cookie: foo=bar\r\n” ] ]; // DOCS: https://www.php.net/manual/en/function.stream-context-create.php $context = stream_context_create($opts); // Open the file using the HTTP headers set above // DOCS: https://www.php.net/manual/en/function.file-get-contents.php $file = file_get_contents(‘http://www.example.com/’, false, $context); You … Read more

Set cookies for cross origin requests

Cross site approach To allow receiving & sending cookies by a CORS request successfully, do the following. Back-end (server) HTTP header settings: Set the HTTP header Access-Control-Allow-Credentials value to true. Make sure the HTTP headers Access-Control-Allow-Origin and Access-Control-Allow-Headers are set. Don’t use a wildcard *. When you set the allowed origin make sure to use … Read more

How to configure static content cache per folder and extension in IIS7?

You can set specific cache-headers for a whole folder in either your root web.config: <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <!– Note the use of the ‘location’ tag to specify which folder this applies to–> <location path=”images”> <system.webServer> <staticContent> <clientCache cacheControlMode=”UseMaxAge” cacheControlMaxAge=”00:00:15″ /> </staticContent> </system.webServer> </location> </configuration> Or you can specify these in a web.config file in … Read more

How to prevent http file caching in Apache httpd (MAMP)

Tried this? Should work in both .htaccess, httpd.conf and in a VirtualHost (usually placed in httpd-vhosts.conf if you have included it from your httpd.conf) <filesMatch “\.(html|htm|js|css)$”> FileETag None <ifModule mod_headers.c> Header unset ETag Header set Cache-Control “max-age=0, no-cache, no-store, must-revalidate” Header set Pragma “no-cache” Header set Expires “Wed, 11 Jan 1984 05:00:00 GMT” </ifModule> </filesMatch> … Read more