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 4608770
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:53:32+00:00 2026-05-22T00:53:32+00:00

I just started using SimpleXML to get a feed and display data from that

  • 0

I just started using SimpleXML to get a feed and display data from that XML feed on one of my webpages. See my first post https://stackoverflow.com/questions/5925368/how-to-use-the-weather-gov-xml-feed-on-a-website I have a basic knowledge of PHP so I may be missing something basic.

If I understand what is happening correctly, every time someone looks at my page before it displays the php, the script first has to go and get the feed. Then it does what I have asked it to do with the feed and then displays the page.

I would think everything would be faster if I was to cache either the feed or formatted the feed and cache that. Which is better caching the raw feed or format the feed and cache the result? How do I go about caching either?

I am hoping that someone can point me in the direction of a tutorial that will teach me how to cache things with php or maybe someone has some example code that I could learn from and/or adapt for my project?

Thanks.

  • 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-22T00:53:32+00:00Added an answer on May 22, 2026 at 12:53 am

    Google “simple php cache tutorial” or look at this one.

    Instead of echo or print-ing text to the screen as you probably are now, build up a variable using the technique of string concatenation like so:

    $html = '<h3>Weather View</h3>';
    
    foreach( element in your xml feed){
    $html .= 'Some more information';
    }
    //then when done
    file_put_contents('weather_cache.txt', $html );
    

    Essentially you ought to cache a segment of html, which you then use PHP to include at the correct place in your webpages, probably using file_get_contents();

    The logic in the tutorial will tell you how to check the date of the cache and then decide to a) go and refresh the xml and recreate the cache or b) lift up and display the cached file

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

Sidebar

Related Questions

I just started using Resharper. One of its features is that it suggests changes
I just started using the WPF WebBrowser that is included in Net 3.5 SP1.
I just started using SVN, and I have a cache directory that I don't
just started using log4j in one of my home-projects and I was just about
I just started using MySQL and I just can see myself woking with strings!
Ive just started using WCF with silverlight and its working fine. But one thing
I just started using CakePHP and it's very different from just normal procedural or
Just started using CodeIgniter, loving it. Having enabled the database to be one of
I just started using datatables (java script) for tabular data, due to js I
Just started using log4net and trying to get my head around the config and

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.