Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Diana Burduja

    (@diana_burduja)

    No, the number doesn’t change, it stays the same.

    You’re right, I didn’t think about circumventing the caching. I’ll work on that in the following days. But I guess a better approach is to add a GET parameter to the url (“?ver=1”) instead of changing the file number.

    Plugin Author Diana Burduja

    (@diana_burduja)

    In the 2.0 version I’ve implemented that. Now there is a “?v=number” at the end of the linked JS or CSS files.

    Thread Starter red.green.blue

    (@redgreenblue)

    Cool. Thank you for addressing this so quickly.

    So, I know very little about caching: what I’m about to say could be completely wrong!

    I get the impression that adding a GET parameter results (in many cases) in the page never being cached.

    So if a visitor arrives at my site and view 20 pages, my server has to deliver 20 copies of the same file. The visitor has to wait for the file to download. All-in-all, their experience is degraded.

    If, however, the document name (link) is changed whenever the WordPress Admin updates the file, that file is cached. So my visitor who views 20 pages only makes one request to my server. All subsequent requests are cached. (There may need to be something about adding a htaccess file/php headers in the Uploads directory to help enforce caching there.)

    So – if I am right – the best option might be to remove the ?GET param and just change the file name each time the Admin hits save.

    Please tell me if I’m talking rubbish!

    Plugin Author Diana Burduja

    (@diana_burduja)

    If a visitor is asking 20 times for “style.css?ver=4.2.2”, it will get the cached file. The moment the GET parameter changes, it will retrieve the file from the server and cache it for the future.

    By default WordPress deals with cache circumventing by adding the “?ver=” at the end of the file.

    From wp_enqueue_script():

    $ver
    (string|bool) (Optional) String specifying the script version number, if it has one. This parameter is used to ensure that the correct version is sent to the client regardless of caching, and so should be included if a version number is available and makes sense for the script.
    Default value: false

    What is says is: the file is cached with the “?ver=” at the end, but when the file changes you also need to change the GET parameter to make sure it doesn’t serve the previously cached version.

    Plugin Author Diana Burduja

    (@diana_burduja)

    As a small test I recommend you to open the Apache logs and then browse through the website. In the Apache logs the CSS and JS files should be requested only once.

    Then try to change a code and save it. That will make the browser request the CSS and JS files again, but cache them again.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Caching?’ is closed to new replies.