Button position depending on situation or always in the same position?

I have two situations:

  1. A page with a table. The table can be short or long depending on user preference (items per page).
  2. A page with a form. The form can be short or very long depending on some dynamic data.

I need to place a few things in each page:

  1. A back button.
  2. A search field.
  3. One or two secondary buttons.
  4. A primary button to save user input for the case "page with a form" and open a modal containing a form when we have the case "a page with a table".

My questions are:

  1. Should I keep same position for the buttons whatever the case is? Or should I treat each case separately and for example put the buttons for the "form case" after the form on the left side and keep them top-right for the "table case"?
  2. What do you think about the current order I have? Back button, search, page title, buttons? The back button will not exist in other pages so the search will be the left most in that case.

Thank you.

enter image description here enter image description here