0

Currently I'm working on an application and i have a problem. I want to display an html page but the probem is : there is a lot of data/query behind the page. Is it possible to save the html page with the data every morning and then display the html page saved ? I dont want to load the data every time I load the page because the loading is really long.

I'm working with ZendFramwork and Oracle.

3
  • 1
    Of course it is possible, but implementing your own caching mechanism is probably a waste of your time as there are good caching solutions available on every level (web-server, php, database, etc.). You are probably already using some of them. Commented Jun 28, 2019 at 8:19
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. Commented Jun 28, 2019 at 8:21
  • Search information about Cache (eg. Redis, Varnish,...) and try to implement it ! The idea is to do a task one time and re-use the result instead of redoing the action. You can do it at different level (server, brower...) Commented Jun 28, 2019 at 8:22

4 Answers 4

1

You can use either local storage or session storage for this. HTML web storage provides two objects for storing data on the client:

  • window.localStorage - stores data with no expiration date
  • window.sessionStorage - stores data for one session (data is lost when the browser tab is closed)

Use this link to learn more (https://www.w3schools.com/html/html5_webstorage.asp)

Sign up to request clarification or add additional context in comments.

Comments

0

You can use GitHub Pages, write a script in any language to send data in GitHub web page on your decided time and all done your html page in dynamic but act as a static and loads in no time

Comments

0

I think you want to use frontend cache. There are at least 3 versions of Zend Framework, but the caching si very similar.

For Zend 1 there is some theory https://framework.zend.com/manual/1.12/en/zend.cache.theory.html#zend.cache.clean

Best way is set frontend cache in routes For that, use this in your router definition file

addRoute($router, [
    'url' => "[your-path]",
    'defaults' => [
        'controller'    => '[controller-name]',
        'action'        => '[action-name]',
        'cache'         => [TIME-OF-CACHE] // 2 hours = 7200
    ]
]);

Then, if you really want to delete this cache every morning, you should do it manually, by some CRON script.

For that, try to use this Zend Framework Clearing Cache

Comments

0

Here is the solution:

  1. You need a cron job that runs the script (the HTML file) every morning
  2. Add ob_start() to beginning of your HTML file
  3. Save the buffer into a file :)

    <?php

    ob_start();

    // Display that HTML file here. You don't need to change anything.

    // Add this to the end of your file to output everything into a file.
    $out = ob_get_contents();
    ob_end_clean();
    file_put_contents('cached.html', $out);
    ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.