Issue #3589Opened July 3, 2021by lbmir0 reactions

Autoload storage is not working on page refresh

Question

Hi, firstly I want to say that this project is awesome, thank you!

I used code from GrapeJS Demo example, and added there save and load data from remote files, this is my storageManager code:

 storageManager: {
            id: 'gjs-',             // Prefix identifier that will be used on parameters
            type: 'remote',          // Type of the storage
            autosave: false,         // Store data automatically
            autoload: true,         // Autoload stored data on init
            urlStore: 'save_now.php',
            urlLoad: 'load_now.php',
            params: { page_id: 11111 },
            contentTypeJson: true,
            headers: {
            'Content-Type': 'application/json'
            }
        }

save_now.php file code:

header("Content-Type:application/json");
$data = file_get_contents("php://input");
file_put_contents('test.txt', $data);

load_now.php file code:

header("Content-Type:application/json");
$response = file_get_contents("test.txt");
echo $response;

When I am saving my changes it is working fine, but after that if I am press to Refresh page it loads old content which was before my changes.

But if I use Hard Refresh page than it is content is fine it is showing my last changes.

How can I keep saved content when user refreshing page?

It seems that it is saving old content somewhere and reloading it after refresh but not using urlLoad from storage manager that I defined.

May be there is a way to disable loading of old content and only use urlLoad from storage Manager?

Answers (2)

artfJuly 21, 20210 reactions

Sounds more like an issue from your side, web applications do not distinguish Refresh from Hard Refresh, indeed the Hard Refresh is more like a refresh without the browser local cache. Try to check, from the inspector, if your load call is actually returning the correct data (eg. maybe you have a web server with kind of cache enabled)

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.