Customer subscription rss, timed Update method

Source: Internet
Author: User
Ask a customer to subscribe to RSS, the method of timing updates
A Web site is being made to provide customers with a keyword search to subscribe to local RSS, but in order to protect the number of calls to the database, prepare to limit customer calls.

The general idea is that the first time a user subscribes is to call the database and generate a static XML file. Automatically updated every 24 hours based on the time of the XML generation.

Idea one: Each time the user requests the XML, according to-filectime judgment, if greater than 24*60*60, run the php file again, call the database, update the XML file. The question is, since a static XML file has been generated, how to let the XML notify PHP file, tell it: "I have expired, please update me again"?

Idea two: Write user subscriptions into the shell and let Cron run in the background. The problem is that when the number of user subscriptions increases exponentially, the shell script size increases and becomes burdensome. Also, if the shell script has read and write at the same time, will the shell script crash? or cause a cron program to be skipped?

Thought three: Haven't thought well, perhaps everybody has the better method to suggest to me. Thank you.


BTW: Personal inclination: According to Time ()-filectime, this will eliminate the possibility that a malicious user evaporates after the first subscription (the RSS subscription is discarded), and my cron program is automatically generated for him every 24 hours ...

------Solution--------------------
PHP can read the generation time of XML to judge. However, if you have a large number of XML files, you have to consider the IO bottleneck problem. So if it doesn't work, the generated time will be put into storage. Working with a database may be better

Is there much XML? Not too much, you can use Memcache to match.
------Solution--------------------
1 floor That's what it means.
It's a file cache.

ABCD can be md5 a bit, can prevent some special characters caused by the trouble,
Brute force is not a problem because you can put XML in a directory outside of Web root, or you can use. htaccess to control direct access

There are too many XML files, there will be problems, as needed, you can periodically delete the long-term non-updated files, or sub-directory hierarchy.

Another: If it is a plain XML file, file_get_contents is faster than include


discuss

Hey, think about it, could you? All RSS feeds are defined to a PHP file Rss.php?search=abcd

PHP Code

$file _name = $_get[' Search ']. XML '; Abcd.xml
if (Time ()-filectime ($file _name) >24*60*60) {
Queries the database, generates a new XML file, and is read
}else{
......

------Solution--------------------
XML modification time can use the head method to obtain the last modify time, search engine spiders are doing so.
  • 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.