Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1058931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:05:48+00:00 2026-05-16T18:05:48+00:00

I am writing a proxy service for caching the queries that my mobile app

  • 0

I am writing a proxy service for caching the queries that my mobile app makes to webservice. (like a man in the middle)

The task of proxy site I have built is pass the query it gets from the app onto third party webservice and save the response from the third party webservice as an XML file and for all subsequent calls for the same query read from the XML file and provide the response (basically caching the response -using Php, curl and simplexml_load_file).

Now my question is – What is the recommended way to read an xml file and return the string.

option 1:
$contents = file_get_contents($filename);
echo $contents;

option 2:
$xml=simplexml_load_file($filename)
echo $xml->asXML();

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:05:49+00:00Added an answer on May 16, 2026 at 6:05 pm
    readfile($filename);
    

    file_get_contents/echo first reads the entire contents into the php process’ memory and then sends it to the output stream. It’s not necessary to have the entire content in memory if all you want to do id to forward it.
    simplexml_load_file() not only reads the entire content into memory, it also parses the document which takes additional time. Again unnecessary if you don’t want to get specific data from the document or test/modify it.

    readfile() sends the content directly to the output stream and can do so “any way it see’s fit”. I.e. if supported in can use memory mapped files, if not it can at least read the contents in smaller chunks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im writing a proxy app that is going to be deployed on Amazon EC2.
I'm writing a relatively simple proxy app for a web service. The general idea
I'm writing a middle-tier WCF service that needs to fetch some data from a
i am writing a web proxy in java on google App engine.I figured out
I'm writing a simple Google Web Toolkit service which acts as a proxy, which
I'm writing my first C# web application that connects to an XML based service.
I'm writing a proxy script that ideally does the following things: Proxy waits for
I'm currently writing a proxy application that reads from one socket and writes on
I'm writing a proxy library (called Library A) that is just an interface to
I am writing a C# client that calls a web service written in Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.