Methods for subscribing to RSS and updating regularly-php Tutorial

Source: Internet
Author: User
Ask a customer to subscribe to RSS. the method of regular update is creating a website. the customer can search and subscribe to the local RSS by keyword, but to protect the number of calls of the database, prepare to limit the number of customer calls. The general idea is: the first time a user subscribes, the user calls the database to generate static XML files. Based on the XML generation time, it is automatically updated every 24 hours. Idea 1: Each time a user requests an XML file, the time ()-filectime is used to determine whether a customer needs to subscribe to RSS for a regular update if the time is greater than 24x6.
A website is being created to provide users with a keyword to search and subscribe to the local RSS. however, to protect the number of database calls, you must limit the number of calls.

The general idea is: the first time a user subscribes, the user calls the database to generate static XML files. Based on the XML generation time, it is automatically updated every 24 hours.

Idea 1: Each time a user requests XML, the user determines based on time ()-filectime. if the time is greater than 24*60*60, the user runs the php file again, calls the database, and updates the XML file. The problem is that since a static XML file has been generated, how can I notify the php file in XML to tell it: "I have expired, please update me again "?

Train of Thought 2: write user subscription into SHELL to run CRON on the regular background. The problem is that when the number of user subscriptions doubles, the SHELL script volume increases and becomes heavier. In addition, if the SHELL script is read and written at the same time, will the SHELL script crash? Or is the CRON program skipped?

Thought 3: I haven't thought about it yet. maybe you have a better way to advise me. Thank you.


BTW: personal tendency: determined based on time ()-filectime, this can exclude malicious users from evaporation after the first subscription (RSS subscription is abandoned ), my CRON program is still generating an automatic empty task every 24 hours ......

------ Solution --------------------
Php can read the xml generation time for determination. However, I/O bottlenecks must be considered when there are a large number of xml files. If not, the generated time will be stored in the database. It may be better to use databases for work.

Is there a lot of xml? If not, you can use memcache.
------ Solution --------------------
This is what the first floor means.
Is a file cache.

Abcd can be md5 to prevent the trouble caused by some special characters,
Brute-force cracking is not a problem, because you can place xml in a directory outside the web root, or use. htaccess to control direct access.

Too many xml files may also cause problems. you can regularly delete files that are not updated for a long time or at different directory levels as needed.

In addition, if it is a pure xml file, file_get_contents is faster than include


Discussion

Hey, have you considered it? All RSS subscriptions are defined as a php file rss. php? Search = abcd

PHP code

$ File_name = $ _ GET ['search']. '. XML'; // abcd. xml
If (time ()-filectime ($ file_name)> 24*60*60 ){
// Query the database, generate a new xml file, and then read
} Else {
......

------ Solution --------------------
You can use the head method to get the last modify time for xml modification. search engine spider does this.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.