Avoid caching of the http responses

Server-side cache control headers should look like: Expires: Tue, 03 Jul 2001 06:00:00 GMT Last-Modified: {now} GMT Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate Avoid rewriting URLs on the client because it pollutes caches, and causes other weird semantic issues. Furthermore: Use one Cache-Control header (see rfc 2616) because behaviour with multiple entries is undefined. Also the … Read more

HttpClient Request like browser

Here you go – note you have to decompress the gzip encoded-result you get back as per mleroy: private static readonly HttpClient _HttpClient = new HttpClient(); private static async Task<string> GetResponse(string url) { using (var request = new HttpRequestMessage(HttpMethod.Get, new Uri(url))) { request.Headers.TryAddWithoutValidation(“Accept”, “text/html,application/xhtml+xml,application/xml”); request.Headers.TryAddWithoutValidation(“Accept-Encoding”, “gzip, deflate”); request.Headers.TryAddWithoutValidation(“User-Agent”, “Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 … Read more

using header() to rewrite filename in URL for dynamic pdf

Try: header(‘Content-Disposition: attachment; filename=”July Report.pdf”‘); or header(‘Content-Disposition: inline; filename=”July Report.pdf”‘); Another option would be to use the $_SERVER[‘PATH_INFO’] to pass your “July Report.pdf” – an example link might be: <a href=”https://stackoverflow.com/questions/2015985/report_pdf.php/July%20Report.pdf?month=07″> That file should default to saving as “July Report.pdf” – and should behave exactly like your old php script did, just change the code … Read more

$http Auth Headers in AngularJS

You’re mixing the use cases; instantiated services ($http) cannot be used in the config phase, while providers won’t work in run blocks. From the module docs: Configuration blocks – […] Only providers and constants can be injected into configuration blocks. This is to prevent accidental instantiation of services before they have been fully configured. Run … Read more

Is it OK to HTTP redirect images?

Yes, you can redirect images and browsers will follow redirects. But you’ll generally want to keep redirection to a minimum for performance reasons, because each redirect requires a separate HTTP request, which adds server overhead and increases end-user page load time a little. The one thing you should definitely avoid is redirecting many images on … Read more

Can I change the headers of the HTTP request sent by the browser?

I would partially disagree with Milan’s suggestion of embedding the requested representation in the URI. If anyhow possible, URIs should only be used for addressing resources and not for tunneling HTTP methods/verbs. Eventually, specific business action (edit, lock, etc.) could be embedded in the URI if create (POST) or update (PUT) alone do not serve … Read more

Removing X-Powered-By

I think that is controlled by the expose_php setting in PHP.ini: expose_php = off Decides whether PHP may expose the fact that it is installed on the server (e.g. by adding its signature to the Web server header). It is no security threat in any way, but it makes it possible to determine whether you … Read more