I have many XML-s and I downloaded using file or file_get_content, but the server administrator told me that through GZIP is more efficient the downloading. My question is how can I include GZIP, because I never did this before, so this solution is really new for me.
I have many XML-s and I downloaded using file or file_get_content, but the server
Share
I don’t understand your question.
You say that you downloaded these files – you can’t unilaterally enable compression client-side.
OTOH you can control it server-side – and since you’ve flagged the question as PHP, and it doesn’t make any sense for your administrator to recommend compression where you don’t have control over the server then I assume this is what you are talking about.
In which case you’d simply do something like:
…or maybe this is nothing to do with PHP, and the XML files are static – in which case you’d need to configure your webserver to compress on the fly.
Unless you mean that compression is available on the server and you are fetching data over HTTP using PHP as the client – in which case the server will only compress the data if the client provides an “Accept-Encoding” request header including “gzip”. In which case, instead of file_get_contents() you might use: